Android 弹出Dialog时隐藏状态栏和底部导航栏

时间:2021-08-07 18:07:33

上代码

dialog.getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);
dialog.getWindow().getDecorView().setOnSystemUiVisibilityChangeListener(new View.OnSystemUiVisibilityChangeListener() {
          @Override
          public void onSystemUiVisibilityChange(int visibility) {
                  int uiOptions = View.SYSTEM_UI_FLAG_LAYOUT_STABLE |
                  //布局位于状态栏下方
                  View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION |
                  //全屏
                  View.SYSTEM_UI_FLAG_FULLSCREEN |
                  //隐藏导航栏
                  View.SYSTEM_UI_FLAG_HIDE_NAVIGATION |
                  View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN;
                  uiOptions |= 0x00001000;
                  dialog.getWindow().getDecorView().setSystemUiVisibility(uiOptions);
          }
});