一.statysBar颜色设置方法
方法一:
在styles.xml里设置"colorPrimaryDark"的值:
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimaryDark">@color/mainColor</item>
</style>
</resources>
方法二:
在styles.xml里设置"statusBarColor"的值:
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="android:statusBarColor">@android:color/black</item>
</style>
</resources>
二.colorPrimaryDark和statusBarColor
不同点:
-1.statusBarColor具有更高的优先级,两个同时出现,statusBarColor会覆盖colorPrimaryDark。
-2.statusBarColor在Android5.0以下的版本中会出现警告。
-3.默认情况下,statusBarColor的值继承自colorPrimaryDark。