如果 RecyclerView 在 LinearLayout 中,AppBarLayout 在更新到设计库 22.2.1 后不会滚动
AppBarLayout doesn't scroll after update to design library 22.2.1, if RecyclerView is inside LinearLayout
将设计库更新到 v22.2.1 后,我的 activity 布局将不再滚动。它在更新之前工作正常。布局如下所示:
<?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>
我唯一能弄清楚的是,如果我将 recyclerView 的父级从 LinearLayout 更改为 FrameLayout,一切正常:
<?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>
我错过了什么?
原来这是v22.2.1的问题;我通过推进到设计库 v23.0.0 来修复它。
将设计库更新到 v22.2.1 后,我的 activity 布局将不再滚动。它在更新之前工作正常。布局如下所示:
<?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>
我唯一能弄清楚的是,如果我将 recyclerView 的父级从 LinearLayout 更改为 FrameLayout,一切正常:
<?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>
我错过了什么?
原来这是v22.2.1的问题;我通过推进到设计库 v23.0.0 来修复它。