"Hidden" 工具栏在状态栏下可见

"Hidden" Toolbar visible under status bar

使用 CoordinatorLayout 在向下滚动时隐藏我的工具栏。

工具栏认为它是隐藏的 - 但它不是。

有人知道为什么会这样吗?

注意:我将状态栏设置为半透明,以便有合适的 material 抽屉。将状态栏设为纯色不是我正在寻找的解决方案 - 当然,除非这是打算使用的方式。

不太确定我做错了什么,但我可以通过以下示例解决此问题:

https://github.com/chrisbanes/cheesesquare/blob/master/app/src/main/res/layout/activity_detail.xml

https://github.com/chrisbanes/cheesesquare/blob/f9eb39d29ea057b56e270263fa26f76e0bf3e77a/app/src/main/res/layout/include_list_viewpager.xml

我尝试将状态栏颜色设置为primarydark,这样当抽屉打开时状态栏不能透明,否则工具栏又出来了。 经过两天的工作,我发现如果我 删除 我的 CoordinatorLayout 中的 android:fitsSystemWindows="true",它就解决了。

<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:openDrawer="start">
<-- CoordinatorLayout is root of @layout/app_bar_home-->
<include
    layout="@layout/app_bar_home"
    android:layout_width="match_parent"
    android:layout_height="match_parent" />

<android.support.design.widget.NavigationView
    android:id="@+id/nav_view"
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    android:layout_gravity="start"
    android:fitsSystemWindows="true"

    app:headerLayout="@layout/nav_header_home"
    app:menu="@menu/activity_home_drawer" />