【发布时间】:2016-06-01 11:16:10
【问题描述】:
我正在处理与 ViewPager、AppBarLayout 和 Toolbar 相关的奇怪问题。
在我的布局中,我有一个标准的 Material Design 设置,例如:
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context="...">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.Toolbar
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="@color/grey_900"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:layout_scrollFlags="scroll|enterAlways" />
<android.support.design.widget.TabLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:tabMode="fixed"
app:tabGravity="fill"
app:tabBackground="@color/grey_900"
app:tabIndicatorColor="@color/white_1000"
app:tabIndicatorHeight="4dp" />
</android.support.design.widget.AppBarLayout>
<android.support.v4.view.ViewPager
android:layout_width="match_parent"
android:layout_height="match_parent" />
<android.support.design.widget.FloatingActionButton
...
app:layout_behavior="com.inkstinctapp.inkstinct.FabBehavior" />
</android.support.design.widget.CoordinatorLayout>
我的 ViewPager 包含 4 个具有这种布局的片段:
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<me.zhanghai.android.materialprogressbar.MaterialProgressBar
android:layout_width="56dp"
android:layout_height="56dp"
android:indeterminate="true"
android:tint="@color/white_1000"
android:layout_centerInParent="true" />
<android.support.v4.widget.SwipeRefreshLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="match_parent" />
</android.support.v4.widget.SwipeRefreshLayout>
</RelativeLayout>
我无法让工具栏滚动,我尝试了以下所有组合:
app:layout_behavior="@string/appbar_scrolling_view_behavior"
app:layout_scrollFlags="scroll|enterAlways"
除非我从我的 viewpager 中删除 appbar_scrolling_view_behavior,否则它们似乎都不起作用,因为 viewpager 位于 AppBarLayout 下方。
我做错了什么?任何帮助将不胜感激!
【问题讨论】:
-
尝试在片段布局中的
RecyclerView中添加app:layout_behavior="@string/appbar_scrolling_view_behavior" -
您使用哪个版本的 appcompat ? 23.2 AppBarLayout + SwipeRefreshLayout + SwipeRefreshLayout 有一些错误
-
@Rehan 没什么,工具栏还是不能滚动.. 顺便谢谢你
-
@marco 我在 23.4.0,可能还有问题
-
更多信息在这里。 code.google.com/p/android/issues/detail?id=201775 23.1.1 一切正常。但我不知道这是否是真正的问题
标签: android android-layout android-fragments android-viewpager android-toolbar