微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

android – CollapsingToolbarLayout有时在下面留下空白

我有个问题.以下是截图:

这里是代码

<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout 
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/drawerLayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

<android.support.design.widget.CoordinatorLayout
    android:id="@+id/rootLayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <android.support.design.widget.AppBarLayout
        android:layout_width="match_parent"
        android:layout_height="256dp"
        android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

        <android.support.design.widget.CollapsingToolbarLayout
            android:id="@+id/collapsingToolbarLayout"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            app:expandedTitleMarginStart="64dp"
            app:layout_scrollFlags="scroll|exitUntilCollapsed">

            <android.support.v7.widget.Toolbar
                android:id="@+id/toolbar"
                android:layout_width="match_parent"
                android:layout_height="?attr/actionBarSize"
                android:background="?attr/colorPrimary"
                android:minHeight="?attr/actionBarSize"
                app:layout_collapseMode="pin"
                app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
                app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" />

        </android.support.design.widget.CollapsingToolbarLayout>

    </android.support.design.widget.AppBarLayout>

    <android.support.v4.widget.nestedScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fillViewport="true"
        app:layout_behavior="@string/appbar_scrolling_view_behavior">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical">

            <Button
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Yo Yo" />

            <Button
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Yo Yo" />

            <Button
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Yo Yo" />

            <Button
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Yo Yo" />

            <Button
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Yo Yo" />

            <Button
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Yo Yo" />

            <Button
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Yo Yo" />

            <Button
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Yo Yo" />

            <Button
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Yo Yo" />

            <Button
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Yo Yo" />

            <Button
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Yo Yo" />

            <Button
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Yo Yo" />

            <Button
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Yo Yo" />

            <Button
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Yo Yo" />

            <Button
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Yo Yo" />

            <Button
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Yo Yo" />

            <Button
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Yo Yo" />

            <Button
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Yo Yo" />

            <Button
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Yo Yo" />

            <Button
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Yo Yo" />

            <Button
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Yo Yo" />

            <Button
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Yo Yo" />

            <Button
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Yo Yo" />

            <Button
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Yo Yo" />
        </LinearLayout>

    </android.support.v4.widget.nestedScrollView>

    <android.support.design.widget.FloatingActionButton
        android:id="@+id/fabBtn2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom|right"
        android:layout_marginBottom="@dimen/codelab_fab_margin_bottom"
        android:layout_marginRight="@dimen/codelab_fab_margin_right"
        app:borderWidth="0dp"
        app:fabSize="normal" />

</android.support.design.widget.CoordinatorLayout>

<android.support.design.widget.NavigationView
    android:id="@+id/navigation"
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    android:layout_gravity="start"
    app:headerLayout="@layout/nav_header"
    app:itemIconTint="@color/colorPrimaryDark"
    app:itemTextColor="@color/colorPrimary"
    app:menu="@menu/navigation_drawer_items" />

您可以看到有时,工具栏下方会出现一个空白区域,但有时候不会.
妳有什么想法有什么问题吗?因为我真的不知道如何解决这个问题.

提前致谢,

编辑:我只能在Nexus 7中使用Android 5.1.1进行复制

解决方法

this answer所示,尝试添加
android:layout_gravity="fill_vertical"

nestedScrollView / RecyclerView.

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐