Search code examples
androidstylesandroid-manifeststatusbar

How to change the colour of the statusbar in android?


This is my style

 <style name="NoActionbar" parent="android:style/Theme.NoTitleBar">

    <item name="android:statusBarColor">#1c465d</item>

</style

>

I want to change the splash screen, by remove the actionbar but i realise the default status bar colour is black, I am not able to change the colour of statusbar to green

why is this show?

How can I do it?


Solution

  • As stated above, set the colorPrimaryDark attribute in your style to whatever you like.

    <resources>
      <!-- inherit from the material theme -->
      <style name="AppTheme" parent="android:Theme.Material">
        <!-- Main theme colors -->
        <!--   your app branding color for the app bar -->
        <item name="android:colorPrimary">@color/primary</item>
        <!--   darker variant for the status bar and contextual app bars -->
        <item name="android:colorPrimaryDark">@color/primary_dark</item>
        <!--   theme UI controls like checkboxes and text fields -->
        <item name="android:colorAccent">@color/accent</item>
      </style>
    </resources>
    

    http://developer.android.com/training/material/theme.html

    To do it correctly you should declare your color value in the color.xml, then reference it from the style.