Android中修改状态栏的颜色和我们App的风格一致

其实也没什么东西,就是一个主题,下面看代码:

<resources>

    <!-- Base application theme. -->
    <style name="AppTheme" parent="AppBaseTheme">
        <!-- Customize your theme here. -->
    </style>
 <!-- 状态栏的样式 -->
    <!--  -->
    <style name="AppBaseTheme" parent="Theme.AppCompat.Light">
        <item name="colorPrimary">@color/bar_back_color_main</item>
        <item name="colorPrimaryDark">@color/bar_back_color_main</item>
        <item name="colorAccent">@color/bar_back_color_main</item>
    </style>

</resources>

      重要的三条属性:

  • colorPrimary------------对应ActionBar的颜色。
  • colorPrimaryDark-------对应状态栏的颜色
  • colorAccent------------对应EditText编辑时、RadioButton选中、CheckBox等选中时的颜色。
原文地址:https://www.cnblogs.com/819158327fan/p/4902746.html