[Android]通知栏与操作栏的高度-State Bar & Navigation Bar

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;
}
上一篇:Win10 UWP 开发系列:使用多语言工具包让应用支持多语言


下一篇:[C++]四种方式求解最大子序列求和问题