Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/200.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 安卓抽屉导航暗模式,带透明状态栏_Android_Navigation Drawer_Android Dark Theme - Fatal编程技术网

Android 安卓抽屉导航暗模式,带透明状态栏

Android 安卓抽屉导航暗模式,带透明状态栏,android,navigation-drawer,android-dark-theme,Android,Navigation Drawer,Android Dark Theme,我在应用程序中使用导航抽屉,并尝试实现黑暗主题。当应用程序未覆盖整个屏幕且状态栏不透明时,navigationView会自动着色为黑色。但是,当应用程序覆盖整个屏幕且状态栏透明时,navigationView将保持白色。即使应用程序覆盖整个屏幕并且状态栏是透明的,我如何强制navigationView变暗 我没有明确设置背景色或文本颜色,它使用默认值 布局代码如下所示: <androidx.drawerlayout.widget.DrawerLayout xmlns:android="h

我在应用程序中使用导航抽屉,并尝试实现黑暗主题。当应用程序未覆盖整个屏幕且状态栏不透明时,navigationView会自动着色为黑色。但是,当应用程序覆盖整个屏幕且状态栏透明时,navigationView将保持白色。即使应用程序覆盖整个屏幕并且状态栏是透明的,我如何强制navigationView变暗

我没有明确设置背景色或文本颜色,它使用默认值

布局代码如下所示:

<androidx.drawerlayout.widget.DrawerLayout 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"
        xmlns:tools="http://schemas.android.com/tools"
        android:orientation="vertical"
        android:id="@+id/drawer_layout">

<!-- Some other views wrapped in RelativeLayout -->

    <com.google.android.material.navigation.NavigationView
        android:id="@+id/mainnav"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        app:menu="@menu/mainmenu"
        android:layout_gravity="start"
        app:headerLayout="@layout/mainmenu_header"
        android:fitsSystemWindows="false"
        app:insetForeground="@null">

        <include android:id="@+id/mainmenuheader"
            layout="@layout/mainmenu_header"/>

    </com.google.android.material.navigation.NavigationView>
</androidx.drawerlayout.widget.DrawerLayout>
<style name="Theme.AppCompat.Light.NoActionBar.FullScreen" parent="@style/Theme.AppCompat.Light.NoActionBar">
    <item name="android:windowTranslucentStatus">true</item>
    <item name="android:windowTranslucentNavigation">true</item>
</style>

活动使用透明状态栏全屏显示的样式如下所示:

<androidx.drawerlayout.widget.DrawerLayout 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"
        xmlns:tools="http://schemas.android.com/tools"
        android:orientation="vertical"
        android:id="@+id/drawer_layout">

<!-- Some other views wrapped in RelativeLayout -->

    <com.google.android.material.navigation.NavigationView
        android:id="@+id/mainnav"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        app:menu="@menu/mainmenu"
        android:layout_gravity="start"
        app:headerLayout="@layout/mainmenu_header"
        android:fitsSystemWindows="false"
        app:insetForeground="@null">

        <include android:id="@+id/mainmenuheader"
            layout="@layout/mainmenu_header"/>

    </com.google.android.material.navigation.NavigationView>
</androidx.drawerlayout.widget.DrawerLayout>
<style name="Theme.AppCompat.Light.NoActionBar.FullScreen" parent="@style/Theme.AppCompat.Light.NoActionBar">
    <item name="android:windowTranslucentStatus">true</item>
    <item name="android:windowTranslucentNavigation">true</item>
</style>

真的
真的
最后,在活动a的清单中,应用主题并将fitsSystemWindows设置为true:



你这么做是为了什么?我编辑了问题并添加了我使用的代码