How to change StatusBar color

1

I'm trying to change the colors of my StatusBar, but when I try to change the colorPrimaryDark (first bar, where the battery is, time, etc ...) the color does not change.

I created an xml with the values of the colors used

colors.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>

<color name = "primary">#162d50</color>
<color name = "primary_dark">#010101</color>
<color name = "textprimary">#FFFFFF</color>


</resources>

And my styles.xml is like this

styles.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>

<style name="AppTheme" parent="android:Theme.Material.Light">

        <item name="android:colorPrimary">@color/primary</item>
        <item name="android:colorPrimaryDark">@color/primary_dark</item>
        <item name="android:textColorPrimary">@color/textprimary</item>


</style>

</resources>

I can change all the colors, background, color of the title bar, color of the text, however the colorPrimaryDark, regardless of the value inserted does not change the color, it always remains black, can anyone help me please?     

asked by anonymous 18.10.2017 / 02:03

1 answer

2

To change the color of the StatusBar you must use the android:statusBarColor attribute.

<style name="AppTheme" parent="android:Theme.Material.Light">

    <item name="android:colorPrimary">@color/primary</item>
    <item name="android:colorPrimaryDark">@color/primary_dark</item>
    <item name="android:textColorPrimary">@color/textprimary</item>

    <item name="android:statusBarColor">@color/cor_da_statusbar</item>
</style>

References:

18.10.2017 / 11:54