我正在开发一个Activity我需要使导航栏不透明的地方,状态栏在运行5.0+(API 21+)的设备上是透明的.我正在使用的样式如下,以及我的问题的解释.
AppTheme 扩展 Theme.AppCompat.Light.NoActionBar
<item name="android:statusBarColor">@color/transparent</item>
<item name="android:windowActionBar">false</item>
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:statusBarColor">@color/welbe_red_transparent</item>
Run Code Online (Sandbox Code Playgroud)
FullscreenTheme 扩展 AppTheme
<item name="android:windowNoTitle">true</item>
<item name="android:statusBarColor">@color/transparent</item>
<item name="android:windowTranslucentNavigation">true</item>
Run Code Online (Sandbox Code Playgroud)
这使得应用程序看起来像这样

如果我删除android:windowTranslucentNavigation样式,或将其设置false在Fullscreen,它修复了导航栏的问题.问题是状态栏变为完全白色而不是保持透明并显示其背后的内容.

我已尝试fitsSystemWindow="true"在我的布局中使用,但它没有解决问题.任何人都知道为什么会这样吗?