一、有个需求是进入app后 隐藏状态栏和导航栏,代码如下
// Hide both the navigation bar and the status bar.
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_FULLSCREEN);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
// Hide Action bar.
ActionBar actionBar = getSupportActionBar();
// Notice:Replace getSupportActionBar() with getActionBar() if you aren't using androidx...
if (actionBar != null) {
actionBar.hide();
}
二、效果如下,进入app后就会隐藏导航栏和状态栏,上滑和下滑会调出来。
三、有价值的参考文章
android 11.0 增加控制状态栏和导航栏的接口_深圳之光的博客-CSDN博客