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
Well, Izhar solution was OK but, personally, I am trying to avoid from code that looks as this:
As well, I don't like to duplicate code either. In your answer I have to add such line of code in all Activities:
So, I took Izhar solution and used XML to get the same result: Create a layout for the StatusBar status_bar.xml
Notice the height and elevation attributes, these will be set in values, values-v19, values-v21 further down.
Add this layout to your activities layout using include, main_activity.xml:
For the Toolbar, add top margin attribute:
In your appTheme style-v19.xml and styles-v21.xml, add the windowTranslucent attr:
styles-v19.xml, v21:
And finally, on your dimens, dimens-v19, dimens-v21, add the values for the Toolbar topMargin, and the height of the statusBarHeight: dimens.xml for less than KitKat:
The status bar height is always 24dp dimens-v19.xml for KitKat and above:
dimens-v21.xml for Lolipop, just add the elevation if needed:
This is the result for Jellybean KitKat and Lollipop: