Search code examples
androidandroid-toolbarandroid-recyclerviewandroid-design-libraryappbar

AppBarLayout doesn't scroll after update to design library 22.2.1, if RecyclerView is inside LinearLayout


after updating the design library to v22.2.1 my activity layout won't scroll anymore. It was working fine prior to the update. The layout looks like this:

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
    style="@style/layout.content"
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto">

    <android.support.design.widget.AppBarLayout
        android:id="@+id/app_bar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:fitsSystemWindows="true">

        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:fitsSystemWindows="true"
            app:layout_scrollFlags="scroll|enterAlways"/>
    </android.support.design.widget.AppBarLayout>

    <FrameLayout
        style="@style/layout.content.root"
        app:layout_behavior="@string/appbar_scrolling_view_behavior">

        <include layout="@layout/progress_bar"/>

        <LinearLayout
            android:id="@+id/content"
            style="@style/layout.content.root">

            <include layout="@layout/layout_search_cities"/>

            <android.support.v7.widget.RecyclerView
                android:id="@+id/recycler_view"
                style="@style/layout.match"
                android:scrollbars="vertical"/>
        </LinearLayout>
    </FrameLayout>
</android.support.design.widget.CoordinatorLayout>

The only thing I could figure out is that if I change the recyclerView's parent from LinearLayout to FrameLayout everything is working fine:

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
    style="@style/layout.content"
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto">

    <android.support.design.widget.AppBarLayout
        android:id="@+id/app_bar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:fitsSystemWindows="true">

        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:fitsSystemWindows="true"
            app:layout_scrollFlags="scroll|enterAlways"/>
    </android.support.design.widget.AppBarLayout>

    <FrameLayout
        style="@style/layout.content.root"
        app:layout_behavior="@string/appbar_scrolling_view_behavior">

        <include layout="@layout/progress_bar"/>

        <FrameLayout
            android:id="@+id/content"
            style="@style/layout.content.root">

            <include layout="@layout/layout_search_cities"/>

            <android.support.v7.widget.RecyclerView
                android:id="@+id/recycler_view"
                style="@style/layout.match"
                android:layout_marginTop="?attr/actionBarSize"
                android:scrollbars="vertical"/>
        </FrameLayout>
    </FrameLayout>
</android.support.design.widget.CoordinatorLayout>

What am I missing?


Solution

  • It turns out that this was an issue with v22.2.1; I fixed it by advancing to design library v23.0.0.