I would like to reproduce the Gmail app status bar behavior on 5.0 as a resume:
- When the Navigation Drawer is closed the status bar color is dark red
- When the navigation drawer is opened it opens under the status bar that is now translucent.
- The Toolbar (former ActionBar) is always under the status bar.
I'm using the compact library v21, and I have added a toolbar to my main activity.xml:
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="?attr/actionBarSize"
android:background="?attr/colorPrimaryDark"
/>
I'm using a theme based on Theme.AppCompat.NoActionBar
1) With that my statusbar is colored, but the navigation drawer is opened just below the status bar, and not under the status bar.
2) Then I make the statusbar translucent adding:
<item name="android:windowTranslucentStatus">true</item>
But this moves up the entire toolbar under the status bar hiding it partially. The navigation drawer is opened under the status bar.
3) To solve it have tried to move down the toolbar with a "margintop" with the size of the statusbar. With that change the statusbar is transparent without color.
4) So my last intent is to add another toolbar with the status bar height, on top of the "toolbar" that is acting as an ActionBar. I colored this toolbar with the darkcolor. The problem is that to make that work it needs to know the statusbar height on all devices.
Also the last one would not work on pre v21 so I would need to use the "new toolbar" only on v21.
All of this seems a little patchy for me so I would like to know if there are another way more "standard" to accomplish such "small" feature.
The solution given at https://stackoverflow.com/a/26440880/557179 only works if the navigation drawer is defined inside the drawerLayout or with an include. But in my case the Navigation drawer is defined as a Fragment on the DrawerLayout hierarchy, and the fitsystemWindows doesn't work.
Thank you!