I am working on an application where I\'m using AppBarLayout with CollapsingToolbarLayout and NestedScrollView. I have successfully implemented this and it is working fine.<
Use support-library 26.0.1 version.
This problem has been solved by google from the support library after version 26.0.0
https://developer.android.com/topic/libraries/support-library/revisions.html#26-0-1
When i was burning my midnight oil this library came like batman
https://github.com/henrytao-me/smooth-app-bar-layout
According to which the behavior can be improved by following these steps:
1.Change
android.support.design.widget.AppBarLayout
to
me.henrytao.smoothappbarlayout.SmoothAppBarLayout and set android:id
2.Remove
app:layout_behavior="@string/appbar_scrolling_view_behavior"
3.Add header to your NestedScrollView or RecyclerView
Which actually made it to work like charm.
The final setup looks like
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v4.widget.NestedScrollView
android:id="@+id/nested_scroll_view"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:paddingTop="@dimen/app_bar_height">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="16dp"
android:layout_marginTop="16dp"
android:text="@string/text_short" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="16dp"
android:text="@string/text_long" />
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
<me.henrytao.smoothappbarlayout.SmoothAppBarLayout
android:id="@+id/smooth_app_bar_layout"
android:layout_width="match_parent"
android:layout_height="@dimen/app_bar_height">
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/collapsing_toolbar_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
app:layout_collapseMode="pin"
app:navigationIcon="@drawable/ic_menu_arrow_back"
style="@style/AppStyle.MdToolbar" />
</android.support.design.widget.CollapsingToolbarLayout>
</me.henrytao.smoothappbarlayout.SmoothAppBarLayout>
</android.support.design.widget.CoordinatorLayout>
If you still face any issue while implementing this ask here i would love to help and mark this up if this answer helps.