How to change the color of the Statusbar?

Asked

Viewed 4,919 times

3

How do I change the color of this part of the app? I wanted to put everything in the same green color as this one below. A parte que esta rodeada de vermelho

2 answers

5


Just 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 it is possible to use the setStatusBarColor()

Here has a Google tutorial on color palette

5

Statusbar color is by default the color assigned to colorPrimaryDark.
In versions below 21 it is only possible to change it by changing the colorPrimaryDark. Which means that every component that uses that color has also changed it.

In equal or higher versions it is possible to do it in the application style 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);

Browser other questions tagged

You are not signed in. Login or sign up in order to post.