First of all it's not a duplicate as in How to change the background color of android status bar
How do I change the status bar color which should be same as in navigation bar.
I want the status bar color to be same as the navigation bar color
First of all it's not a duplicate as in How to change the background color of android status bar
How do I change the status bar color which should be same as in navigation bar.
I want the status bar color to be same as the navigation bar color
One more solution:
If you want to work on Android 4.4 and above, try this. I refer to Harpreet's answer and this link. Android and the transparent status bar
First, call setStatusBarColored method in Activity's onCreate method(I put it in a util class). I use a image here, you can change it to use a color.
Before:
After:
The color of the status bar has been changed, but the navi bar is cut off, so we need to set the margin or offset of the navi bar in the onCreate method.
Then the status bar will look like this.
This is what worked for me in KitKat and with good results.
As @Niels said you have to place in values-v21/styles.xml:
But add
tools:targetApi="lollipop"
if you want single styles.xml, like:Android 5.0 Lollipop introduced Material Design theme which automatically colors the status bar based on the
colorPrimaryDark
value of the theme.This is supported on device pre-lollipop thanks to the library support-v7-appcompat starting from version 21. Blogpost about support appcompat v21 from Chris Banes
Read more about the Material Theme on the official Android Developers website
You can change the status bar color with this function. works on android L means API 21 and higher and needs a color string such as
"#ffffff"
.