[英]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.