使用Design Support Library 22.2.1,具有以下视图层次结构:
<DrawerLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<Toolbar
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize" />
<TabLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clipToPadding="false"
app:tabGravity="fill"
app:tabMode="scrollable" />
</AppBarLayout>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="android.support.design.widget.AppBarLayout$ScrollingViewBehavior">
<!-- Fragments replaced here -->
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<CustomDashboardView
android:layout_width="match_parent"
android:layout_height="120dp" />
<ViewPager
android:layout_width="match_parent"
android:layout_height="match_parent">
<!-- Tab Fragments go here -->
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<CustomEmptyErrorLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone" />
<android.support.v7.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
</ViewPager>
</LinearLayout>
</FrameLayout>
</CoordinatorLayout>
<NavigationView
android:layout_height="match_parent"
android:layout_width="wrap_content"
android:fitsSystemWindows="true" />
</DrawerLayout>
我遇到了这样的问题: RecyclerView 的高度比它应该包含的可见区域要大,因此它看起来像是在屏幕外绘制,而且无法滚动 RecyclerView 的最后一项使其完全显示。工具栏和选项卡布局也没有移动(尽管 FrameLayout 上应用了 layout_behaviour)。 我已经将这个问题报告为一个bug,但是Banesy老师说这是按照预期工作的。如果是这样,我该如何避免这种预期行为,而选择一个Respect Layout_height="match_parent"并在可见屏幕内绘制其项目的RecyclerView? https://code.google.com/p/android/issues/detail?id=182391 更新:现在使用Design Support v23,情况看起来不太好。我已经缩小了问题范围,发现是Design Support库本身引起的问题(即将RecyclerView、appcompat和其他内容更新到v23,同时保留Design Support v22.2.1会产生与上述描述相同的问题)。所以新的外观,CustomDashboardLayout和RecyclerView都消失了,希望这也不是按照预期工作的: