I would recommend using the new Google support design library.
Include it in your dependencies:
compile 'com.android.support:design:22.2.0'
and then use AppBarLayout along with NestedScrollView .
For your Toolbar define an app:layout_scrollFlags="scroll|enterAlways" which says that it will disappear when scrolling and will immediately return if you scroll up (this means you don't have to scroll all the way up).
<android.support.design.widget.AppBarLayout android:id="@+id/appbar" android:layout_width="match_parent" android:layout_height="wrap_content" android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"> <android.support.v7.widget.Toolbar android:id="@+id/toolbar" android:layout_width="match_parent" android:layout_height="?attr/actionBarSize" android:background="?attr/colorPrimary" app:popupTheme="@style/ThemeOverlay.AppCompat.Light" app:layout_scrollFlags="scroll|enterAlways" /> </android.support.design.widget.AppBarLayout> <android.support.v4.widget.NestedScrollView android:layout_width="match_parent" android:layout_height="match_parent" android:layout_gravity="fill_vertical" app:layout_behavior="@string/appbar_scrolling_view_behavior"> <FrameLayout android:id="@+id/container" android:layout_width="match_parent" android:layout_height="match_parent"/> </android.support.v4.widget.NestedScrollView>
Kuba spatny
source share