MIUI 状态栏主题问题

问题描述

我正在尝试在 Miui 中实现透明状态栏。

我尝试了从样式到窗口标志的所有方法,但没有任何效果

ScreenShot

主题

 <!-- Status bar. -->
    <item name="android:windowTranslucentStatus">true</item>
    <item name="android:windowTranslucentNavigation">true</item>
    <item name="android:windowIsTranslucent">true</item>
    <item name="windowNoTitle">true</item>
    <item name="windowActionBar">false</item>
    <item name="android:fitsSystemWindows">true</item>
    <item name="android:statusBarColor">@android:color/transparent</item>

和窗口标志

 window.setFlags(
        WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS,WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS
    )
    val decorView = window.decorView
    decorView.fitsSystemWindows = true
    window.decorView.systemUIVisibility = View.SYstem_UI_FLAG_LAYOUT_STABLE or View.SYstem_UI_FLAG_LAYOUT_FULLSCREEN or View.SYstem_UI_FLAG_LIGHT_STATUS_BAR
    window.statusBarColor = Color.TRANSPARENT

我还能做些什么来隐藏状态栏?

解决方法

or View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR 中删除此 window.decorView.systemUiVisibility = ...

,

这些资源帮助我解决了问题

https://medium.com/androiddevelopers/gesture-navigation-going-edge-to-edge-812f62e4e83e

还有一个代码实验室

https://codelabs.developers.google.com/codelabs/gesture-navigation#3