Android获取系统顶部状态栏(Status Bar)与底部导
2017-10-11 本文已影响280人
闫鹏飞写字的地方
1.获取顶部status bar 高度
private int getStatusBarHeight() {
Resources resources = mActivity.getResources();
int resourceId = resources.getIdentifier("status_bar_height", "dimen","android");
int height = resources.getDimensionPixelSize(resourceId);
Log.v("dbw", "Status height:" + height);
return height;
}
2.获取底部 navigation bar 高度
private int getNavigationBarHeight() {
Resources resources = mActivity.getResources();
int resourceId = resources.getIdentifier("navigation_bar_height","dimen", "android");
int height = resources.getDimensionPixelSize(resourceId);
Log.v("dbw", "Navi height:" + height);
return height;
}