Status bar with three-color gradient in Android Studio

1

It's like doing a status bar with a 3-color gradient (as in the image).

    
asked by anonymous 05.05.2018 / 19:10

2 answers

2

For the versions from the API 21 you could set the color of the status bar as follows: Set up your app's 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">@drawable/statusbar_degrade</item>
</style>

And the Drawable file that will generate the color set for your gradient:

<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item>
    <shape android:shape="rectangle">
        <gradient android:centerColor="#3046d7"
            android:startColor="#58d445"
            android:endColor="#1b8f0b" />
    </shape>
</item>
</selector>

Then you can set the colors and gradient format within the statusbar_degrade file you created in the @drawable folder.

    
05.05.2018 / 20:26
1

I have never tried but I believe you should create a gradient in xml and apply it as background in your bar status, it follows a gradient template with only two colors:

    <item android:state_pressed="true">
        <shape>
            <solid android:color="@android:color/holo_blue_light"></solid>
        </shape>
    </item>

    <item>
        <shape>
            <solid android:color="@android:color/white"></solid>
        </shape>
    </item>
</selector>

Then apply this xml as backgroud of your statusbar

    
05.05.2018 / 20:15