1.通知栏
public static int getStatusBarHeight() {
Resources resources = Resources.getSystem();
int resourceId = Resources.getSystem().getIdentifier("status_bar_height",
"dimen", "android");
if (resourceId > 0) {
return resources.getDimensionPixelSize(resourceId);
}
return 0;
}
2.虚拟键操作栏
public static int getNavigationBarHeight() {
Resources resources = Resources.getSystem();
int resourceId = resources.getIdentifier("navigation_bar_height",
"dimen", "android");
if (resourceId > 0) {
return resources.getDimensionPixelSize(resourceId);
}
return 0;
}