【Android】隐藏底部虚拟按键
生活随笔
收集整理的這篇文章主要介紹了
【Android】隐藏底部虚拟按键
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
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);?
原文:
但是,有個問題。
這樣的確能隱藏底部虛擬導(dǎo)航欄,但是一旦你點擊屏幕,導(dǎo)航欄會出現(xiàn)(持續(xù)1秒左右),并且消費掉你的點擊事件。如果你要點擊一個按鈕(導(dǎo)航欄隱藏狀態(tài)下),你需要連續(xù)點兩次。因為1秒鐘之后,導(dǎo)航欄又消失了,點擊屏幕事件會被再次攔截消費。
最終的解決方案
/*** 隱藏虛擬按鍵,并且全屏*/protected void hideBottomUIMenu() {//隱藏虛擬按鍵,并且全屏if (Build.VERSION.SDK_INT > 11 && Build.VERSION.SDK_INT < 19) { // lower apiView 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);}}轉(zhuǎn)載于:https://www.cnblogs.com/dongweiq/p/8078585.html
總結(jié)
以上是生活随笔為你收集整理的【Android】隐藏底部虚拟按键的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 对AutoIt中控件和窗口的理解
- 下一篇: 应用程序域