I am trying to create a navigation drawer from the hardware specifications (as in a new gmail application). Notice how the content of the navigation panel is drawn behind the status bar:
Thanks to Chris Baines’ answer to this question, I was able to successfully move the navigation field behind the status bar in my application; it works very well. What doesn’t work is drawing the contents of the navigation box behind the status bar. I want the blue image of my box to appear behind the status bar, but this area is drawn in the color of the status bar, as shown in this screenshot.
How do I get the navigation box drawn in the area behind the status bar? I have published the relevant parts of my project below.
Basic Layout Containing a Navigation Field :
The theme of my activities
In onCreate() of my company, I do the following:
How can I solve this problem?
For API 21+
For API 19+
Your layout should have android:fitsSystemWindows=false (default).
If you now want to change the translucency, you can do so per program:
Window = getWindow() ;
// Enable Status Bar Transparency (API 19 required)
// Disable transparency of status strings (API 19 required)
window.getAttributes().flags &= (~WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS) ;
// set color (API 21 required)
I’ll leave it to you to look at all the versions of sdk.
If you want to change the color (other than transparent black) of the status bar, you need to take a different approach with a custom view, because mDrawerLayout.setStatusBarBackgroundColor(int) is only enabled if this DrawerLayout matches SystemWindows (android:fitsSystemWindows=true), and if it does, it is drawn below the status bar, not behind it.
I found a better way to do this on Android 5.0. The important thing is to use ScrimInsetFrameLayout as the base element of the navigation box (second view in DrawerLayout). This requires expanding the content to fill the space behind the status bar. You can set the following attribute in ScrimInsetFrameLayout to color the insertion correctly:
Also make sure that android:fitsSystemWindows=true is configured for the grid layout!
The source code for ScrimInsetFrameLayout can be found here: https://github.com/google/iosched/blob/master/android/src/main/java/com/google/samples/apps/iosched/ui/widget/ScrimInsetsFrameLayout.java.
For those who struggle with a semi-transparent status bar combined with the nav bar, but don’t want to change.
fitssystemwindows, navigation drawer over status bar android, navigation drawer over action bar android, android show content behind status bar, setonapplywindowinsetslistener, "setdecorfitssystemwindows", fitssystemwindows not working in fragment, android navigation drawer above status bar, hide status bar android – stack overflow, hide status bar and toolbar android, how to hide systembar in android, hide action bar android, systemuivisibility deprecated, how to remove title bar in android studio, navigation drawer in android medium, navigation drawer alternative, react-navigation drawer status bar, navigationcontainer status bar, react native status bar, react native drawer, navigation drawer on top of status bar android, navigation drawer status bar android, fitssystemwindows not working, drawerlayout status bar color