Let's practice how to control the System UI by referring to the
Android documentation
👆👆
Download PPT : https://github.com/ggujangi/ggu.system.ui/files/4094927/System.UI.Visibility.ppt.pptx
SYSTEM_UI_FLAG_LOW_PROFILE
flagsetSystemUiVisibility()
with SYSTEM_UI_FLAG_VISIBLE
flag clears all flagsView mDecorView = getActivity().getWindow().getDecorView();
int mOption = View.SYSTEM_UI_FLAG_LOW_PROFILE;
mDecorView.setSystemUiVisibility(mOption);
// clear all flags
mDecorView.setSystemUiVisibility(SYSTEM_UI_FLAG_VISIBLE);
<application
...
android:theme="@android:style/Theme.Holo.NoActionBar.Fullscreen">
...
</application>
WindowManager
flagsWindowManager
flags, the flags remain in effect unless your app clears themFLAG_LAYOUT_IN_SCREEN
to set your activity layout to use the same screen area that's available when you've enabled FLAG_FULL_SCREEN
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
setSystemUiVisibility()
with SYSTEM_UI_FLAG_FULLSCREEN
flag hides the status bar View mDecorView = getActivity().getWindow().getDecorView();
int mOption = View.SYSTEM_UI_FLAG_FULLSCREEN;
mDecorView.setSystemUiVisibility(mOption);
onCreate()
won't get called, so if you want system UI changes to persist, set UI flags in onResume()
of onWindowFocusChanged()
SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
, the content will not be resized when the navigation bar is hidden and visible.SYSTEM_UI_FLAG_LAYOUT_STABLE
helps your app maintain a stable layout.android:fitsSystemWindows
adjusts the padding of the parent ViewGroup
and if set to true the app's UI will not be covered by the system barsetSystemUiVisibility()
with SYSTEM_UI_FLAG_HIDE_NAVIGATION
flag hides the navigation barSYSTEM_UI_FLAG_FULLSCREEN
flag together. This works the same as Lean back
in Full screen OptionsView mDecorView = getActivity().getWindow().getDecorView();
int mOption = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
// Hide both the navigation bar and the status bar
int bothOption = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_FULLSCREEN;
mDecorView.setSystemUiVisibility(mOption);
SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
, the content will not be resized when the navigation bar is hidden and visibleSYSTEM_UI_FLAG_LAYOUT_STABLE
helps your app maintain a stable layout
setSystemUiVisibility()
with SYSTEM_UI_FLAG_FULLSCREEN
and SYSTEM_UI_FLAG_HIDE_NAVIGATION
View mDecorView = getActivity().getWindow().getDecorView();
int mOption = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_FULLSCREEN;
mDecorView.setSystemUiVisibility(mOption);
setSystemUiVisibility()
with SYSTEM_UI_FLAG_IMMERSIVE
and SYSTEM_UI_FLAG_FULLSCREEN
, SYSTEM_UI_FLAG_HIDE_NAVIGATION
View mDecorView = getActivity().getWindow().getDecorView();
int mOption = View.SYSTEM_UI_FLAG_IMMERSIVE
| View.SYSTEM_UI_FLAG_FULLSCREEN
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
mDecorView.setSystemUiVisibility(mOption);
setSystemUiVisibility()
with SYSTEM_UI_FLAG_IMMERSIVE_STICKY
and SYSTEM_UI_FLAG_FULLSCREEN
, SYSTEM_UI_FLAG_HIDE_NAVIGATION
View mDecorView = getActivity().getWindow().getDecorView();
int mOption = View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
| View.SYSTEM_UI_FLAG_FULLSCREEN
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
mDecorView.setSystemUiVisibility(mOption);