我希望使我的Android应用程序全屏,但只显示在特定屏幕上的android导航栏(我的设置屏幕)。我知道将导航栏永久隐藏在屏幕上是危险的,但我想知道这是否可能。我已经研究过如何在我的设备上生根,并使用。
是否有一种方式以编程方式禁用导航栏或“粘滞模式”,并在以后重新启用?
编辑:我看过Android浸没模式,但似乎导航栏仍然会显示用户是否接触到边缘。我想删除导航栏的任何提示,直到它们转到我的设置屏幕。
发布于 2016-07-07 19:59:00
是的是可能的。使用下面的代码片段来实现所需的功能。
// This snippet hides the system bars.
private void hideSystemUI() {
// Set the IMMERSIVE flag.
// Set the content to appear under the system bars so that the content
// doesn't resize when the system bars hide and show.
View decorView = getWindow().getDecorView();
decorView.setSystemUiVisibility(
View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION // hide nav bar
| View.SYSTEM_UI_FLAG_FULLSCREEN // hide status bar
| View.SYSTEM_UI_FLAG_IMMERSIVE);
}
// This snippet shows the system bars. It does this by removing all the flags
// except for the ones that make the content appear under the system bars.
private void showSystemUI() {
View decorView = getWindow().getDecorView();
decorView.setSystemUiVisibility(
View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
}有关更多细节,请参阅以下google文档:
https://developer.android.com/training/system-ui/immersive.html
编辑1:要永久地隐藏它,你可以尝试这样的方法(哈基)
decorView.setOnSystemUiVisibilityChangeListener
(new View.OnSystemUiVisibilityChangeListener() {
@Override
public void onSystemUiVisibilityChange(int visibility) {
hideSystemUI();
}
});`https://stackoverflow.com/questions/38254127
复制相似问题