Basically what I want to do is when the user rotates their phone (Landscape) it goes into FullScreen and hides both the bottom and top status bars, I'm using this...
@Override
public void onWindowFocusChanged(boolean hasFocus) {
super.onWindowFocusChanged(hasFocus);
if (hasFocus) {
hideSystemUI();
}
}
private void hideSystemUI() {
View decorView = getWindow().getDecorView();
decorView.setSystemUiVisibility(
View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
| View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
// Hide the nav bar and status bar
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_FULLSCREEN);
}
and it works perfectly in portrait mode, now when the user rotates his phone (in landscape mode) I want the status bars to hide and go into fullscreen mode. how can I do it?
To achieve what you want, define a type variable
Bundle
at the class levelOverwrite the change config methods to detect rotation, and call the method to hide the status bar when the orientation is
LANDSCAPE
(horizontal):Finally, inside your
AndroidManifest.xml
want to manually manage configuration changes in your application , you must declare the attributeandroid:configChanges
with the following value: