ggujangi / ggu.system.ui

Control System UI Visibility Practice
Apache License 2.0
4 stars 0 forks source link
android navigation-bar status-bar system-ui visibility

Control the System UI Visibility:penguin:

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


INDEX


1. Dimming the System Bars

Dim the Status and Navigation Bars

Reveal the Status and Navigation Bars

View mDecorView = getActivity().getWindow().getDecorView();
int mOption = View.SYSTEM_UI_FLAG_LOW_PROFILE;
mDecorView.setSystemUiVisibility(mOption);
// clear all flags
mDecorView.setSystemUiVisibility(SYSTEM_UI_FLAG_VISIBLE);


2. Hiding the Status Bar

Hide the Status Bar on Android 4.0 and Lower

  getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);


Hide the Status Bar on Android 4.1 and Higher

  View mDecorView = getActivity().getWindow().getDecorView();
  int mOption = View.SYSTEM_UI_FLAG_FULLSCREEN;
  mDecorView.setSystemUiVisibility(mOption);


Make Content Appear Behind the Status Bar



3. Hiding the Navigation Bar

Hide the Navigation Bar

View 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);

Make Content Appear Behind the Navigation Bar

4. Using Immersive Full-Screen Mode

Lean Back

View mDecorView = getActivity().getWindow().getDecorView();
int mOption = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
          | View.SYSTEM_UI_FLAG_FULLSCREEN;
mDecorView.setSystemUiVisibility(mOption);





Immersive

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);




Sticky Immersive

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);