In the new lollipop update I noticed that with the native Google apps the color of the status bar changes to match the action bar on the app you're running. I see it's on the Twitter app also so I'm guessing it's not exclusively Google who can do it.
Does anyone know how to do this if it is possible?
Another way to set the status bar color is through the style.xml.
To do that, create a style.xml file under res/values-v21 folder with this content:
Edit: as pointed out in comments, when using AppCompat the code is different. In file res/values/style.xml use instead:
Just add this in you styles.xml. The colorPrimary is for the action bar and the colorPrimaryDark is for the status bar.
This picture from developer android explains more about color pallete. You can read more on this link.
To set the status bar color, create a style.xml file under res/values-v21 folder with this content:
Add this line in style of v21 if you use two style.
Also if you want different
status-bar
color for different activity (fragments) you can do it with following steps (work on API 21 and above):First create
values21/style.xml
and put following code:Then define White|Dark themes in your
values/style.xml
like following:Also don't forget to apply themes in your
manifest.xml
.In android pre Lollipop devices you can do it from SystemBarTintManager If you are using android studio just add Systembartint lib in your gradle file.
Then in your activity