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>
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11

那么其中的colorPrimarycolorPrimaryDarkcolorAccent分别代表什么呢?看下图就可以一目了然:

style

2、更改colorPrimarycolorPrimaryDark

colorPrimarycolorPrimaryDark的颜色换成你需要改变的颜色即可。

比如,我在values/colors.xml中定义了颜色:

<color name="myBarColor">#0682AF</color>

那么将colorPrimarycolorPrimaryDark的颜色换成@color/myBarColor即可:

<item name="colorPrimary">@color/myBarColor</item>
<item name="colorPrimaryDark">@color/myBarColor</item>

猜你喜欢

转载自blog.csdn.net/qq_37217804/article/details/80321891