我正在按照developer.google的主题教程进行操作。我正在尝试将应用程序迁移到Mat.3,并将状态栏的颜色修改为与背景颜色匹配。
在添加
android:statusBarColor
和android:windowLightStatusBar
后,没有任何变化。我注意到在应用程序加载的最初时刻,状态栏确实符合我的期望,但过了一会儿就变成了错误的状态。
之前的状态:https://istack.dev59.com/i43cL.webp
之后:https://istack.dev59.com/kMwaP.webp 我的尝试:// res/values/themes.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Theme.Superheroes" parent="android:Theme.Material.Light.NoActionBar">
<item name="android:statusBarColor">@color/background_light</item>
<item name="android:windowLightStatusBar">true</item>
<item name="android:windowBackground">@color/background_light</item>
</style>
</resources>
// res/values-night/themes.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Theme.Superheroes" parent="android:Theme.Material.NoActionBar">
<item name="android:statusBarColor">@color/background_dark</item>
<item name="android:windowLightStatusBar">false</item>
<item name="android:windowBackground">@color/background_dark</item>
</style>
</resources>