问题描述
我正在尝试在 Miui 中实现透明状态栏。
主题:
<!-- 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