public static int getNavigationBarHeight(Activity context) {
int height;
Display display = context.getWindow().getWindowManager().getDefaultDisplay();
Point point = new Point();
display.getRealSize(point);
View decorView = context.getWindow().getDecorView();
Configuration conf = context.getResources().getConfiguration();
if (Configuration.ORIENTATION_LANDSCAPE == conf.orientation) {
View contentView = decorView.findViewById(android.R.id.content);
height = Math.abs(point.x - contentView.getWidth());
} else {
Rect rect = new Rect();
decorView.getWindowVisibleDisplayFrame(rect);
height = Math.abs(rect.bottom - point.y);
}
LogUtil.i("getNavigationBarHeight:" + height);
return height;
}
android导航栏高度计算
最新推荐文章于 2024-05-06 00:27:41 发布