简体   繁体   English

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

[英]How to permanently hide navigation bar in android application?

I have a problem hiding navigation bar at the bottom of the screen in android. 我在Android屏幕底部隐藏导航栏时遇到问题。 Every solution I've tried doesn't work exactly as I want it to work, except one. 我尝试过的每种解决方案都不能完全按照我希望的方式工作。 Modifying build.prop with new entry 'qemu.hw.mainkeys=1' worked ok, but it disables navigation bar for whole android system. 使用新条目'qemu.hw.mainkeys = 1'修改build.prop可以正常工作,但是会禁用整个android系统的导航栏。 Is there possibility to disable navigation bar like this only for one app? 是否可以仅针对一个应用程序禁用这样的导航栏?

Try this: 尝试这个:

 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) (资源)

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);

Use this code in onCreate(), it will hide status bar and navigation bar until users swipe down from top of the screen 在onCreate()中使用此代码,它将隐藏状态栏和导航栏,直到用户从屏幕顶部向下滑动

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

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