getWindow().addFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN );
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
actionBar.show();
.. and close:
p>
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?
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.
p>
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();
}
}