【Android】隐藏底部虚拟按键
2017-12-21 09:29
513 查看
Google的官方文档是:
https://developer.android.com/training/system-ui/navigation.html#behind示例代码
1 View decorView = getWindow().getDecorView(); 2 // Hide both the navigation bar and the status bar. 3 // SYSTEM_UI_FLAG_FULLSCREEN is only available on Android 4.1 and higher, but as 4 // a general rule, you should design your app to hide the status bar whenever you 5 // hide the navigation bar. 6 int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION 7 | View.SYSTEM_UI_FLAG_FULLSCREEN; 8 decorView.setSystemUiVisibility(uiOptions);
原文:
但是,有个问题。
这样的确能隐藏底部虚拟导航栏,但是一旦你点击屏幕,导航栏会出现(持续1秒左右),并且消费掉你的点击事件。如果你要点击一个按钮(导航栏隐藏状态下),你需要连续点两次。因为1秒钟之后,导航栏又消失了,点击屏幕事件会被再次拦截消费。
最终的解决方案
/** * 隐藏虚拟按键,并且全屏 */ protected void hideBottomUIMenu() { //隐藏虚拟按键,并且全屏 if (Build.VERSION.SDK_INT > 11 && Build.VERSION.SDK_INT < 19) { // lower api View v = this.getWindow().getDecorView(); v.setSystemUiVisibility(View.GONE); } else if (Build.VERSION.SDK_INT >= 19) { //for new api versions. View decorView = getWindow().getDecorView(); int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY | View.SYSTEM_UI_FLAG_FULLSCREEN; decorView.setSystemUiVisibility(uiOptions); } }
相关文章推荐
- 【Android】隐藏底部虚拟按键,亲测可用
- Android实现隐藏手机底部虚拟按键
- android 隐藏手机底部虚拟按键
- 隐藏Android底部的虚拟按键
- android隐藏底部虚拟键Navigation Bar实现全屏
- Android 4.4.2 横屏应用如何隐藏状态栏和底部虚拟键
- android隐藏底部虚拟键Navigation Bar实现全屏
- Android 4.4.2 横屏应用隐藏状态栏和底部虚拟键的方法
- Android 解决底部弹出PopWindow时如果有虚拟按键遮挡问题
- 三分钟彻底禁用、隐藏Android设备底部虚拟按钮(亲测有效)
- 隐藏Android下的虚拟按键
- 关于Android开发中手机底部虚拟键的隐藏问题
- android隐藏底部虚拟键Navigation Bar实现全屏
- Android 隐藏底部虚拟键的两种方法
- Android 隐藏和显示虚拟按键
- Android底部虚拟按键遮挡popwindow问题
- android 虚拟导航挡住应用底部解决方案(屏幕底部的三个按键)
- android隐藏底部虚拟键Navigation Bar实现全屏
- 全屏实现-去除android盒子底部的虚拟导航按键
- 全屏实现-去除android盒子底部的虚拟导航按键