Java android:windowLightStatusBar和导航抽屉之间的问题

Java android:windowLightStatusBar和导航抽屉之间的问题,java,android,Java,Android,我已将android:windowLightStatusBar设置为true,以便在我的应用程序内的状态栏上显示黑色图标和文本,如下图所示 但是,导航抽屉不再适合屏幕,请参见下图。这是因为要确保android:windowLightStatusBar正常工作,android:windowTranslucentStatus必须设置为false。有解决办法吗?像谷歌日历这样的应用程序似乎可以很好地使用这个功能 这是我的主要活动XML <android.support.v4.widget.D

我已将android:windowLightStatusBar设置为
true
,以便在我的应用程序内的状态栏上显示黑色图标和文本,如下图所示

但是,导航抽屉不再适合屏幕,请参见下图。这是因为要确保
android:windowLightStatusBar
正常工作,
android:windowTranslucentStatus
必须设置为false。有解决办法吗?像谷歌日历这样的应用程序似乎可以很好地使用这个功能

这是我的主要活动XML

<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:background="@color/colorToolbarBackground"
    android:fitsSystemWindows="true"
  >

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

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

        <FrameLayout
            android:id="@+id/frame"
            android:layout_width="match_parent"
            android:layout_height="match_parent" />
    </LinearLayout>


    <android.support.design.widget.NavigationView

        android:id="@+id/navigation_view"
        android:background="@color/colorWhite"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_gravity="start"

        app:menu="@menu/navigation_view_items" />

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

layout.xml

android:fitsSystemWindows="true"
<style name="AppTheme.NoActionBar">
    <item name="windowActionBar">false</item>
    <item name="windowNoTitle">true</item>
    <item name="android:windowDrawsSystemBarBackgrounds">true</item>
    <item name="android:statusBarColor">@android:color/transparent</item>
</style>
并将其添加到
styles-v21.xml

android:fitsSystemWindows="true"
<style name="AppTheme.NoActionBar">
    <item name="windowActionBar">false</item>
    <item name="windowNoTitle">true</item>
    <item name="android:windowDrawsSystemBarBackgrounds">true</item>
    <item name="android:statusBarColor">@android:color/transparent</item>
</style>

Manifest.xml
中,将其添加到活动主目录中

android:theme="@style/AppTheme.NoActionBar"
并将
AppBarLayout
标记包装到以下位置:

<android.support.design.widget.CoordinatorLayout 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:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true"
    tools:context=".MainActivity">

    <!-- Here AppBarLayout ecc -->

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

<!-- Here NavigationView ecc -->

你想要NavigationDrawer重叠状态栏吗?是的,像Google Calendar请添加你的布局。xmlI添加了xmlit现在可以工作了,你是天才,你能解释为什么使用CoordinatorLayout包装可以工作吗?CoordinatorLayout用于与一个或多个子视图的特定交互,请看这里