如何在 Android 应用代码中隐藏导航栏

use*_*263 1 navigation android hide tablet adk

我将此代码添加到我的应用程序中;

View decorView = getWindow().getDecorView();
// Hide both the navigation bar and the status bar.
int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
              | View.SYSTEM_UI_FLAG_FULLSCREEN;
decorView.setSystemUiVisibility(uiOptions);
Run Code Online (Sandbox Code Playgroud)

但是代码迫使我将“SuppressLint NewApi 添加到 MainActivity”。另外还有一个关于“View.SYSTEM_UI_FLAG_FULLSCREEN”的错误。代码说“CHANGE TO....”所以我不知道我必须做什么。

请帮助我。非常感谢。

Rah*_*ina 5

这是在活动中隐藏导航栏的简单代码。这是工作。

getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
Run Code Online (Sandbox Code Playgroud)