Android L中,如何得知是否有虚拟按键呢。查看了下PhoneWindowManager中的代码,这会在这整理处如下方法:
获取是否存在NavigationBar:
private static boolean checkDeviceHasNavigationBar(Context context) {
boolean hasNavigationBar = false;}
获取NavigationBar的高度:
private static int getNavigationBarHeight(Context context) {
int navigationBarHeight = 0;
Resources rs = context.getResources();
int id = rs.getIdentifier("navigation_bar_height", "dimen", "android");
if (id > 0 && checkDeviceHasNavigationBar(context)) {
navigationBarHeight = rs.getDimensionPixelSize(id);
}
return navigationBarHeight;
}