I have an issue with CollapsingToolbarLayout when I perform a very fast jerk. The same thing happens with hidding appBar & tablayout.
I need toolbar to hide on scrolling and CollapsingToolbar to collapse. And it works fine when scroll's not so quick.
But when it's quick - it seems that appBar collapses and expandes right after that. But it hasn't to expand back.
Please take a look at videos.
It seems this answer is what I need but it doesn't work.
xml of my CollapsingToolbarLayout :
<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:background="@color/colorLightGray"
android:clickable="true"
android:fitsSystemWindows="true"
android:orientation="vertical"
>
<android.support.design.widget.AppBarLayout
android:id="@+id/app_bar_layout"
android:layout_width="match_parent"
android:layout_height="200dp"
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="match_parent"
android:fitsSystemWindows="true"
android:minHeight="?attr/actionBarSize"
app:contentScrim="?attr/colorPrimary"
app:expandedTitleMarginEnd="64dp"
app:expandedTitleMarginStart="48dp"
app:layout_scrollFlags="scroll|exitUntilCollapsed|snap"
>
<ImageView
android:id="@+id/ivSectionCover"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
android:scaleType="centerCrop"
app:layout_collapseMode="parallax"
/>
<ImageView
android:layout_width="match_parent"
android:layout_height="130dp"
android:layout_gravity="bottom"
android:alpha="0.5"
android:scaleType="fitXY"
app:layout_collapseMode="pin"
app:srcCompat="@drawable/background_gradient"
/>
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_collapseMode="pin"
app:layout_scrollFlags="scroll|enterAlways"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
/>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<TextView
android:id="@+id/tvEmptyList"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="@string/books_empty_list"
android:textColor="@color/colorGray"
android:textSize="18sp"
android:visibility="gone"
/>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="?attr/actionBarSize"
android:clickable="true"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
>
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clickable="true"
android:fillViewport="true"
>
<RelativeLayout
android:id="@+id/rlContent"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clickable="true"
>
<android.support.v7.widget.RecyclerView
android:id="@+id/rvBooksSection"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="4dp"
android:layout_marginLeft="4dp"
android:layout_marginRight="4dp"
android:layout_marginTop="4dp"
android:clickable="true"
/>
</RelativeLayout>
</android.support.v4.widget.NestedScrollView>
<View
android:layout_width="match_parent"
android:layout_height="4dp"
android:background="@drawable/toolbar_dropshadow"
/>
</RelativeLayout>
</android.support.design.widget.CoordinatorLayout>