In this app I\'m building, I\'ve added a Navigation Drawer fragment into my activity. I\'m using 5.0, so I\'ve been able to set the primaryColor and primaryColorDark to get
With the setup you have, the Nav Drawer is simply a view drawing its background (which you have defined as android:background="@color/WindowBackground"
) underneath the status bar (the color of which you have set to transparent via your StatusBarActivityTheme
). The system only looks as far as the Activity theme to set the status bar color; assigning android:statusBarColor
to a child has no effect.
The simple solution would be to change your Nav Drawer fragment layout's android:background
to the color you desire. If you wish for the portion below your image to remain white, an option would be to then add an empty View in your drawer layout with android:background="@color/WindowBackground"
or some other color.
If you desire for the content in your Nav Drawer to extend below the status bar, it requires a bit more work. The reason it is offset to begin with is because you set the android:fitsSystemWindows
attribute to true, which in turn calls the view's default fitSystemWindows(). As the docs explain, this method takes the inset (i.e. the height of the status bar in our case) and applies it as the view's padding (in your case, this becomes top padding for the RelativeLayout
of your Nav Drawer fragment).
One way to circumvent this padding is to overwrite the view's fitSystemWindows()
method. I direct you to the open source IO Schedule app by Google - specifically, they used the ScrimInsetsScrollView as the root element in their Nav Drawer. This modified ScrollView
applies a scrim of a color of your choice (set via the custom app:insetForeground
attribute) and consumes the inset, i.e. no more padding!
The ScrimInsetsScrollView
can be used as a model to write your own version for any View descendant, really - see the nigh identical ScrimInsetsFrameLayout.