I'm trying to realize a translucent statusbar (so that my navigation-view is BEHIND the statusbar) but still like to change the color of my actionbar dynamically. Because of this, the statusbar color needs to change to a darker version of my actionbar color.
If I set my statusbar to transparent, as many sources suggest, my primary_dark color is used as the background of my statusbar. However, as I will change the actionbar color during runtime, primary_dark must not necessarily be the dark color of my actionbar.
If I set my statusbar to the actionbar color, the transparency is gone. If I set my statusbar to the actionbar color and add transparency, the statusbar looks neither wrong nor right and my overlapping navigationview is still not very 'transparent' / 'colorful'.
Google Inbox has three separate colors: Inbox (blue), Snoozed (yellow) and Done (green).
What can I do to achieve this behaviour?
Actually, it's fairly easy to implement.
First step - is to change height of the
Toolbar
:height
towrap_content
so for me it looks like this:
Then you override resources for
v19
:Then, in the
Activity
, settingpadding
for theToolbar
:And actually, it's pretty much it. Now once I want to change colour of the Toolbar, I'm calling this:
The activity's layout:
NB! On pre-Kitkat OS-versions, status bar remained the same, non-translucent.
I've uploaded the source code of the test-application to my dropbox - feel free to check it out.
I hope, it helps