如何永久隐藏Android应用程序中的导航栏?

时间:2015-11-05 16:34:04

标签: android android-navigation

我在android中屏幕底部隐藏导航栏时遇到问题。 我尝试的每个解决方案都不能完全按照我希望的方式工作,除了一个。 使用新条目'qemu.hw.mainkeys = 1'修改build.prop工作正常,但它禁用整个android系统的导航栏。 是否有可能只为一个应用程序禁用这样的导航栏?

2 个答案:

答案 0 :(得分:0)

试试这个:

View decorView = getWindow().getDecorView();
// Hide both the navigation bar and the status bar.
// SYSTEM_UI_FLAG_FULLSCREEN is only available on Android 4.1 and higher, but as
// a general rule, you should design your app to hide the status bar whenever you
// hide the navigation bar.
int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_FULLSCREEN;
decorView.setSystemUiVisibility(uiOptions);
(Source)

答案 1 :(得分:0)

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

在onCreate()中使用此代码,它会隐藏状态栏和导航栏,直到用户从屏幕顶部向下滑动