Created
August 11, 2016 06:02
-
-
Save bensonmacharia/29f16542abd2a9d8444e9cec45c66910 to your computer and use it in GitHub Desktop.
How to hide toolbar after collapsing while recyclerView scrolling down
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<android.support.design.widget.CoordinatorLayout | |
android:id="@+id/careers_coordinator_layout" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
android:fitsSystemWindows="true" | |
xmlns:android="http://schemas.android.com/apk/res/android" | |
xmlns:app="http://schemas.android.com/apk/res-auto" | |
tools:context=".activity.CareersActivity" | |
xmlns:tools="http://schemas.android.com/tools"> | |
<android.support.design.widget.AppBarLayout | |
android:id="@+id/appBar" | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content" | |
android:fitsSystemWindows="true" | |
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"> | |
<android.support.design.widget.CollapsingToolbarLayout | |
android:id="@+id/collapsing_toolbar" | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content" | |
android:fitsSystemWindows="true" | |
app:contentScrim="?attr/colorPrimary" | |
app:layout_scrollFlags="scroll|enterAlways|enterAlwaysCollapsed"> | |
<ImageView | |
android:id="@+id/background" | |
android:layout_width="match_parent" | |
android:layout_height="256dp" | |
android:scaleType="centerCrop" | |
android:fitsSystemWindows="true" | |
app:layout_collapseMode="parallax" | |
android:src="@drawable/placeholder"/> | |
<android.support.v7.widget.Toolbar | |
android:id="@+id/toolbar" | |
android:layout_width="match_parent" | |
android:layout_height="?attr/actionBarSize" | |
app:contentScrim="?attr/colorPrimary" | |
android:fitsSystemWindows="true" | |
app:titleTextColor="@color/main_color_white" | |
app:popupTheme="@style/ThemeOverlay.AppCompat.Light" | |
app:layout_collapseMode="pin"/> | |
</android.support.design.widget.CollapsingToolbarLayout> | |
<android.support.design.widget.TabLayout | |
android:id="@+id/tabs" | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content" | |
android:background="?attr/colorPrimary" | |
app:tabIndicatorColor="@color/colorAccent" | |
app:tabSelectedTextColor="@color/colorAccent" | |
app:tabTextColor="@android:color/white" | |
app:tabIndicatorHeight="4dp" | |
app:tabMode="fixed"/> | |
</android.support.design.widget.AppBarLayout> | |
<android.support.v4.view.ViewPager | |
android:id="@+id/viewpager" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
app:layout_behavior="@string/appbar_scrolling_view_behavior" /> | |
</android.support.design.widget.CoordinatorLayout> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For
CollapsingToolbarLayout
use scroll flags:this flag combination will disappear toolbar while scrolling down. And
CollapsingToolbarLayout
will expand fully when you scroll to top of the list.And no need to remove
app:layout_collapseMode="pin"
fromToolbar
, becausecollapseMode
flags are to define behavior and placement of views insideCollapsingToolbarLayout
and will not effect actual collapsing and expansion ofCollapsingToolbarLayout
.