Android 11 进入app后 隐藏状态栏和导航栏

一、有个需求是进入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博客

android11屏蔽导航栏_无风之翼的博客-CSDN博客_android禁用导航栏

Android 11隐藏状态栏和导航栏_偷窃月亮的贼的博客-CSDN博客_android11隐藏状态栏

猜你喜欢

转载自blog.csdn.net/qq_37858386/article/details/125804589
今日推荐