android - CoordinatorLayout 滚动后在底部留下空白空间

标签 android material-design android-coordinatorlayout android-collapsingtoolbarlayout coordinator-layout

我正在尝试使用 CoordinatorLayout 实现 Google 的最新设计技巧,但在滚动和视差效果方面存在问题。

显示 Activity 后,一切正常,但当我尝试滚动时出现问题。似乎底部 View 未正确展开,向上滚动后,下方出现空白区域。底部 View 似乎只有在顶部 View 和导航栏之间的初始显示时才大。

看起来像这样:

enter image description here

相关代码:

<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/

相关文章:

android - 父 NestedScrollView 禁用所有功能

android - 使用 AsyncTask 时同步线程的问题,Android

java - 如何为膨胀 View 中的按钮添加 OnclickListener()?

javascript - 使用 mdl 将表格宽度设置为 100% 但不起作用

android - 如何更改抽屉导航的 TextView 中图标和文本的颜色?

javascript - 在 Javascript 中设置多个小图像(如轮播)

android - CoordinatorLayout 内的 NestedScrollView 内的 RecyclerView

android - Recyclerview 滚动在嵌套 ScrollView 中的 fragment 中不起作用

Android OpenGL ES 透明背景

android - 新的动态功能模块和热插拔