// This snippet hides the system bars.
2 private void hideSystemUI() {
3 // Set the IMMERSIVE flag.
4 // Set the content to appear under the system bars so that the content
5 // doesn't resize when the system bars hide and show.
6 //开启全屏模式
7 mDecorView.setSystemUiVisibility(
8 View.SYSTEM_UI_FLAG_LAYOUT_STABLE
9 | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
10 | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
11 | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION // hide nav bar
12 | View.SYSTEM_UI_FLAG_FULLSCREEN // hide status bar
13 | View.SYSTEM_UI_FLAG_IMMERSIVE);
14 }
15
16 // This snippet shows the system bars. It does this by removing all the flags
17 // except for the ones that make the content appear under the system bars.
18 //取消全屏模式
19 private void showSystemUI() {
20 mDecorView.setSystemUiVisibility(
21 View.SYSTEM_UI_FLAG_LAYOUT_STABLE
22 | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
23 | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
24 }