CollapsingToolbarLayout有时在下面留下空白空白、CollapsingToolbarLayout

2023-09-07 16:53:08 作者:微信扫描或直接搜索关注“腾牛个性网”微信公众号,方便随时查看

我有一个问题。以下是截图:

I have a problem. Here are the screenshots:

这里是code:

<?xml version="1.0" encoding="utf-8"?>

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

您可以有时会看到,一个白色的空间出现在工具栏下方,但有时没有。窦哟有什么不对任何想法?因为我真的不知道如何解决这个问题。

You can see sometimes, a white space appears below the Toolbar, but sometimes no. Dou yo have any idea of what's wrong? Because I really don't know how to fix this.

由于提前,

编辑:我可以在Nexus的采用Android 5.1.1复制本7

推荐答案

作为this回答,试着加入:

android:layout_gravity="fill_vertical"

NestedScrollView / RecyclerView