Android – the status bar covered Overlay Action Bar

I am trying to switch my application between true full screen (no status bar, no action bar) and “normal mode” (action bar and status bar). For this , I set an operation bar in the overlay mode, I allow the user to switch the operation bar and the status bar:

getWindow().addFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN );
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
actionBar.show();

.. and close:

getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
actionBar.hide();

< p>It works fine with just one exception: whenever these operations happen, the size of the actual layout will be adjusted. Well, there is another flag, obviously just for this, so I added to my onCreate():< /p>

getWindow().addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);

Ok, now resizing is no longer a problem, but now my operation The bar is half-hidden by the status bar, as long as both are open:

Is there anything I miss? How to make the operation bar be displayed right below the status bar?

After trial and error, I found a solution. This will hide the action bar and status bar, and Does not cause the image to be resized.

private void toggleFullscreen(boolean on) {
ActionBar actionBar = getActionBar();
View decorView = getWindow().getDecorView();

if (on) {
decorView.setSystemUiVisibility(
View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
| View .SYSTEM_UI_FLAG_FULLSCREEN);
actionBar.hide();
}
else {
decorView.setSystemUiVisibility(
View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LAYOUT);FULLSCREE
actionBar.show();
}

}

I’m trying to make my application in real Switch between full screen (no status bar, no operation bar) and “normal mode” (operation bar and status bar). To this end, I set up an operation bar in the overlay mode, and I allow users to switch the operation bar and status bar:

getWindow().addFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); 
actionBar.show();

.. and close:

< pre>getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
actionBar.hide();

Only It works fine with one exception: whenever these operations occur, the size of the actual layout will be adjusted. Well, there is another flag, obviously just for this, so I added to my onCreate():

getWindow().addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);

Ok, now resizing is no longer a problem, but now my action bar is in the state The bar is half-hidden, as long as both are open:

Is there anything I miss? How to make the operation bar be displayed right below the status bar?

After trial and error, I found a solution. This will hide the action bar and status bar without causing the image to resize.

private void toggleFullscreen(boolean on) {
ActionBar actionBar = getActionBar();
View decorView = getWindow().getDecorView();

if (on) {
decorView.setSystemUiVisibility(
View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
| View.SYSTEM_UI_FLAG_FULLSCREEN);
actionBar.hide( );
}
else {
decorView.setSystemUiVisibility(
View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
actionBar.show();
}

}

Leave a Comment

Your email address will not be published.