我在Application中都有样式文件,并且没有将colorPrimaryDark作为状态栏颜色。我正在检查Nexus 6并且它无法使用它。这是我缺少的东西。
style.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>
style.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>
清单 - 任何活动中都没有定义主题
<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>
答案 0 :(得分:1)
尝试在<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>
答案 1 :(得分:0)
将父级更改为“Theme.AppCompat.Light.NoActionBar”
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
</resources>