滚动时工具栏无法完全隐藏

3
我尝试在滚动时隐藏工具栏,但是出现了这种情况!我该怎么办?
以下是布局代码:
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout   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"
android:fitsSystemWindows="true">

<android.support.design.widget.AppBarLayout
    android:id="@+id/appbar"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:theme="@style/SimpleTheme.AppBarOverlay">

    <android.support.v7.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:background="?attr/colorPrimary"
        app:layout_scrollFlags="scroll|enterAlways"
        app:popupTheme="@style/SimpleTheme.PopupOverlay" />

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

<include layout="@layout/content_main" />

<android.support.design.widget.FloatingActionButton
    android:id="@+id/fab"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="bottom|end"
    android:layout_margin="@dimen/fab_margin" />

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

视图容器具有以下行为:
app:layout_behavior="@string/appbar_scrolling_view_behavior"

截图: 滚动前 滚动后


你在主题中使用了 windowDrawSystemBackgrounds 吗? - Jan Heinrich Reimer
1个回答

9

在'fitsSystemWindows'方面有一些问题 将其在coordinatorLayout中设置为false,在AppBarLayout中设置为true


1
这部分代码有一定效果,但是不知何故失去了状态栏的colorPrimaryDark效果。 - Henrique de Sousa
很好。有效。为什么这个答案没有被接受?@Jan-LkElse - ahmadalibaloch
谢谢你,你救了我! - Dark Leonhart

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接