[英]Android : check wether action button (home,back, etc.. ) is inside the screen or not?
我想更詳細地解釋,
一些android設備具有這樣的操作按鈕,
雖然某些設備具有
在第一種情況下,所有動作按鈕都在屏幕外,而在第二種情況下,動作按鈕位於屏幕底部(在屏幕內)...我如何檢測到該動作按鈕在哪里? 我對此一無所知..!
查看Android官方文檔: http : //developer.android.com/reference/android/view/KeyCharacterMap.html#deviceHasKey%28int%29
deviceHasKey方法將解決您的問題。 (使用鍵碼KEYCODE_MENU,KEYCODE_HOME,KEYCODE_BACK)。 希望能幫助到你。
也許通過在您的onCreate()
進行以下檢查:
適用於api 14及更高版本
boolean PermanentMenuKey = ViewConfiguration.get(this).hasPermanentMenuKey(); // true if physical, false if virtual
對於較低的api:
boolean hasBackKey = KeyCharacterMap.deviceHasKey(KeyEvent.KEYCODE_BACK);
boolean hasHomeKey = KeyCharacterMap.deviceHasKey(KeyEvent.KEYCODE_HOME);
if (hasBackKey && hasHomeKey) {
// no navigation bar, unless it is enabled in the settings
} else {
// 99% sure there's a navigation bar
}
您可以在這里得到答案。 檢查導航欄
ps該欄的正式名稱是“導航欄”
https://developer.android.com/training/system-ui/navigation.html
在這里找到了解決方案,但不是100%保證所有設備都能正常工作,某些設備(例如HTC,LAVA等)無法正常工作。 minApi還需要13 + ... !!
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.