6

I've found strange behavior in RecyclerView with CollapsingToolbarLayout. When I scroll RecyclerView - it works perfectly. But when I try to fling it and stop that fling fast enough - I can see, that RecyclerView is scrolled "inside itself".

Bad fling behavior:

RecyclerView should not be scrollable before CollapsingToolbarLayout fully collapses, but it is (in normall scroll everything works perfectly, problem only appears when flinging).

enter image description here

My layout looks like this:

<android.support.design.widget.CoordinatorLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="kg.nongrate.arseniii.collapsingtoolbarlayouttest.MainActivity">

    <android.support.design.widget.AppBarLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <android.support.design.widget.CollapsingToolbarLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            app:layout_scrollFlags="scroll|exitUntilCollapsed">

            <TextView
                android:layout_width="match_parent"
                android:layout_height="240dp"
                android:layout_marginTop="?attr/actionBarSize"
                android:background="@color/colorPrimary"
                android:text="1. Hello World!\n\n\n2. Hello World!\n\n\n3. Hello World!"
                android:textColor="@color/colorAccent"
                app:layout_collapseMode="parallax"
                app:layout_collapseParallaxMultiplier="0.7"
                android:gravity="center" />

            <android.support.v7.widget.Toolbar
                android:id="@+id/toolbar"
                android:layout_width="match_parent"
                android:layout_height="?attr/actionBarSize"
                android:background="?attr/colorPrimaryDark"
                android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
                app:layout_collapseMode="pin"
                app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />

        </android.support.design.widget.CollapsingToolbarLayout>
    </android.support.design.widget.AppBarLayout>


    <android.support.v7.widget.RecyclerView
        android:id="@+id/recyclerView"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="#0cc"
        app:layout_behavior="@string/appbar_scrolling_view_behavior" />

</android.support.design.widget.CoordinatorLayout>

Here are sources and two videos that show what I mean: https://NonGrate@bitbucket.org/NonGrate/collapsingtoolbarlayout-recyclerview-bug.git

NonGrate
  • 862
  • 9
  • 22

0 Answers0