How to change the color of StatusBar?

3

How do I change the color of this part of the app? I wanted everything from the same green color like this one down.

    
asked by anonymous 07.07.2017 / 14:47

2 answers

5

Only edit your file styles.xml

<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
    <item name="colorPrimaryDark">@color/suaCor</item>
</style>

Depending on the API permissions you can use the setStatusBarColor ()

Here has a Google color palette tutorial

    
07.07.2017 / 14:54
5

StatusBar color is by default the color assigned to colorPrimaryDark . In versions lower than 21 you can only change it by changing colorPrimaryDark . That implies that all components that use this color have also changed.

In equal or higher versions you can do this in the style of the application using android:statusBarColor

<resources>
    <!-- Base application theme. -->
    <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
        <!-- Customize your theme here. -->
        <item name="colorPrimary">@color/colorPrimary</item>
        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
        <item name="colorAccent">@color/colorAccent</item>

        <item name="android:statusBarColor">#ff00</item>
    </style>
</resources>

or, via code

getWindow().setStatusBarColor(Color.RED);
    
07.07.2017 / 15:36