我正在尝试使用 CoordinatorLayout 实现 Google 的最新设计技巧,但在滚动和视差效果方面存在问题。
显示 Activity 后,一切正常,但当我尝试滚动时出现问题。似乎底部 View 未正确展开,向上滚动后,下方出现空白区域。底部 View 似乎只有在顶部 View 和导航栏之间的初始显示时才大。
看起来像这样:
相关代码:
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<CoordinatorLayout
android:layout_height="match_parent"
android:layout_width="match_parent">
<AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<CollapsingToolbarLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_scrollFlags="scroll|exitUntilCollapsed"
app:expandedTitleMarginStart="72dp"
app:expandedTitleMarginEnd="16dp">
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_collapseMode="parallax"/>
</CollapsingToolbarLayout>
</AppBarLayout>
<ViewPager
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"/>
</CoordinatorLayout>
</FrameLayout>
这种奇怪的行为是随机发生的。有时底部 View 可以正常滚动并且不会出现空白区域。我究竟做错了什么?谢谢。
最佳答案
我有同样的问题,我注意到每个有这个问题的布局都有
android:fitsSystemWindows="true"
在 CoordinatorLayout 上
删除它解决了我的问题。
关于android - CoordinatorLayout 滚动后在底部留下空白空间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32727029/