My Hexaville
Spead the Word

Android Animated Status Bar Color

android animated status bar color

Designed by Freepik

Hi, I got few ideas about animating status bar color change, you can do it within one activity or as activity transition. Let’s see what I got here.

Simple Animation

So without further adieu here’s some simple status bar color change animation

android animated status bar color

This animation is best for smooth activity transitions, when content changes. That’s three colors animating sequentially and it’s slow intentionally to enjoy this cool transition.

I used this kind of animation for my app‘s intro. Basically I just copied the code from stack. Here’s main class

then you create new instance of it with start/end colors and use with method with float from 0 to 1 to animate it. I’m using ObjectAnimator for it. If you want to read more about animations – check some of those posts

as you see, setStatusBarColor method is used for setting status bar color

API Requirement

Of course, this requires api 21

Gradient Animation

To make it more impressive I deiced to use a gradient transition animation. Gradients are more Apply style, but why not, let’s try how it looks

android animated status bar color

It’s not perfect, but I see how it could work. First of all colors should match toolbar nicely, animating toolbar isn’t a great idea probably, but some glow animation like from the sun showing up randomly in the app is kinda cool? I hope it is

To draw a gradient status bar you need to make it translucent and draw a view of its size underneath with gradient background

For you style and then I have two gradient drawables and animation list for them

Then set last animated drawable list for background for status bar view and animate in in Java

Which To Pick

None of that stuff is in material design , but as a cool experiment I’ll try to improve this gradient animation and see if it feels alright

Thanks for reading!



About the Author Ihor Klimov

Formerly an Android developer, lately picked up some Flutter. This blog is everything that I find exciting about Android and Flutter development. Stay tuned and hope to see you again!