要获取操作栏大小,我可以使用?android:attr/actionBarSize
。导航栏是否有类似内容?
默认值为48dp。虽然,没有大小的属性。唯一的方法似乎是通过这样的代码:
private int getNavigationBarHeight(Context context, int orientation) {
Resources resources = context.getResources();
int id = resources.getIdentifier(
orientation == Configuration.ORIENTATION_PORTRAIT ? "navigation_bar_height" : "navigation_bar_height_landscape", "dimen", "android");
if (id > 0) {
return resources.getDimensionPixelSize(id);
}
return 0;
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句