繁体   English   中英

android中完全隐藏导航栏(不仅仅是按钮)

[英]Completely hiding navigation bar (not only buttons) in android

我正在使用来自最新 Android Studio(2021.2.1 补丁 2)的“导航抽屉活动”模板作为开始。

如何完全隐藏导航栏? 以下代码仅隐藏按钮,但导航栏的白色背景仍然存在。

View decorView = getWindow().getDecorView();
int uiOptions = SYSTEM_UI_FLAG_LAYOUT_STABLE
              | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
              | View.SYSTEM_UI_FLAG_FULLSCREEN;
decorView.setSystemUiVisibility(uiOptions);

谢谢。

在活动的onCreate()中应用此代码:

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
            if (window != null) {
                window.decorView.windowInsetsController!!.hide(WindowInsets.Type.statusBars())
                window.decorView.windowInsetsController!!.hide(
                    WindowInsets.Type.statusBars() or WindowInsets.Type.navigationBars()
                )
            }
        } else {
            val decorView = window.decorView
            val uiOptions = View.SYSTEM_UI_FLAG_FULLSCREEN or View.SYSTEM_UI_FLAG_LAYOUT_STABLE
            decorView.systemUiVisibility = uiOptions
        }

java 版本:

WindowCompat.setDecorFitsSystemWindows(getWindow(), false);
getWindow().getInsetsController().hide(WindowInsetsCompat.Type.systemBars());

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM