Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/207.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 导航组件-fitsSystemWindows工作不正常_Android_Kotlin - Fatal编程技术网

Android 导航组件-fitsSystemWindows工作不正常

Android 导航组件-fitsSystemWindows工作不正常,android,kotlin,Android,Kotlin,我正在使用SAA(单一应用程序活动)制作一个应用程序,我希望有一个渐变状态栏,使用与我的第一个视图相同的渐变 我正在做一些测试,我无法查看状态栏,在父布局中将fitsystemwindows用作false 看看我现在有什么: <?xml version="1.0" encoding="utf-8"?> <androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://sche

我正在使用SAA(单一应用程序活动)制作一个应用程序,我希望有一个渐变状态栏,使用与我的第一个视图相同的渐变

我正在做一些测试,我无法查看状态栏,在父布局中将
fitsystemwindows
用作false

看看我现在有什么:

   <?xml version="1.0" encoding="utf-8"?>
   <androidx.coordinatorlayout.widget.CoordinatorLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="false"
    tools:context=".MainActivity">

<fragment
        android:id="@+id/content"
        android:name="androidx.navigation.fragment.NavHostFragment"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintBottom_toBottomOf="parent"
        app:defaultNavHost="true"
        app:navGraph="@navigation/nav_graph"
/>
风格

   <item name="android:windowIsTranslucent">true</item>
    <item name="android:windowDrawsSystemBarBackgrounds">false</item>
true
假的
附言: 当我标记“布局”\u“无限制”时效果很好,唯一的问题是当我有表单布局时,我无法调整屏幕大小。所以,我知道使用标志\布局\无限制标志

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        val window = window
        window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS)
        window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS)
        window.statusBarColor = Color.TRANSPARENT
    }
   <item name="android:windowIsTranslucent">true</item>
    <item name="android:windowDrawsSystemBarBackgrounds">false</item>