Search code examples
androidscrollandroid-toolbarandroid-recyclerviewandroid-appbarlayout

Appbar scrolling in android design library 22.2.1 vs 22.2.0


I have a problem with the appbar scrolling feature of the new android design library. Besides the design library, I use support libraries 22.2.1 (AppCompat, Recycler view...).

I have a toolbar with

app:layout_scrollFlags="scroll|enterAlways"

attribute and a ViewPager :

<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" />

with 2 tabs. Tab1 contains Recyclerview1. Tab2 contains a linearLayout with 2 Recyclers view (Recyclerview2 and Recyclerview3) and other views.

When I use com.android.support:design:22.2.0 everything works fine, that is, scrolling vertically in Recyclerview1, Recyclerview2 or Recyclerview3 makes the toolbar scroll automatically.

So the fact that Recyclerview2 and Recyclerview3 are nested in tab2 and not direct siblings of tab2 does not affect the toolbar scrolling behaviour. Exactly what I need.

Unfortunately, the new release of the library, com.android.support:design:22.2.1 , breaks this behaviour. In the 22.2.1 release, only Recyclerview1 makes the toolbar scroll. Nested Recyclerview2 and Recyclerview3 do not any more.

What is this lib supposed to do exactly in this case ? Is it a new bug in 22.2.1 or a 22.2.0 bug fixed in 22.2.1 ?

(Please note that i also tried to put all views of tab2 in a NestedScrollView but it changed tab2 height to 50 or 60 dp. So I gave up.)


Solution

  • Google answered me the following :

    "Are RecyclerView 2 and 3 large enough to scroll? v22.2.1 will no longer scroll Views do not need to be scrolled." (Project Member #1 [email protected])

    Indeed, RecyclerView 2 was not large enough which explained the issue but RecyclerView 3 was large enough. However, since then, for some reasons (maybe an update of 22.1.1) my RecyclerView 3 now works as expected.

    So just remember that there is a design intent modification in 22.1.1 (not documented if I am not wrong) that "won't scroll Views that do not need to be scrolled".