android 开发 修改系统背景(状态栏颜色、导航栏颜色、标题栏颜色等等)
1、打开values下的styles.xml
发现有以下代码:
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/myBarColor</item>
<item name="colorPrimaryDark">@color/myBarColor</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
</resources>
那么其中的colorPrimary、colorPrimaryDark、colorAccent分别代表什么呢?看下图就可以一目了然:
style
2、更改colorPrimary和colorPrimaryDark
将colorPrimary、colorPrimaryDark的颜色换成你需要改变的颜色即可。
比如,我在values/colors.xml中定义了颜色:
<color name="myBarColor">#0682AF</color>
那么将colorPrimary、colorPrimaryDark的颜色换成@color/myBarColor即可:
<item name="colorPrimary">@color/myBarColor</item>
<item name="colorPrimaryDark">@color/myBarColor</item>