我在应用程序中有两个样式文件,它没有将 colorPrimaryDark 作为状态栏颜色。我正在检查 Nexus 6,但它无法正常工作。是我缺少的东西。
样式.xml
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
</resources>
样式.xml(v21)
<resources>
<!-- Base application theme. -->
<!--Application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="android:windowDrawsSystemBarBackgrounds">false</item>
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<!--All customizations that are NOT specific to a particular API-level can go here. -->
</style>
</resources>
Menifest - 在任何 Activity 中都没有定义主题
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
颜色文件
<color name="colorPrimary">#35734F</color>
<color name="colorPrimaryDark">#35734F</color>
<color name="colorAccent">#D2AB67</color>
最佳答案
尝试添加 <item name="android:windowDrawsSystemBarBackgrounds">true</item>
和 <item name="android:statusBarColor">@android:color/transparent</item>
在你的style.xml(v21)
.
style.xml
<resources>
<!-- Base application theme. -->
<style name="AppBaseTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
<style name="AppTheme" parent="AppBaseTheme">
</resources>
style.xml(v21)
<resources>
<!-- Base application theme. -->
<!--Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:statusBarColor">@android:color/transparent</item>
</style>
</resources>
关于android - ColorPrimaryDark 不是状态栏颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43732440/