有没有办法在类似于下面的xml文件中获得android中导航栏的大小?
android:paddingTop="?android:attr/actionBarSize"
其中actionBarSize是导航栏的大小?
发布于 2014-11-05 20:42:57
在查看android源代码后,它看起来像是导航栏高度的维度:
@android:dimen/navigation_bar_height
There是链接到导航栏的其他维度,示例来自android values/dimens.xml:
<!-- Height of the bottom navigation / system bar. -->
<dimen name="navigation_bar_height">48dp</dimen>
<!-- Height of the bottom navigation bar in portrait; often the same as @dimen/navigation_bar_height -->
<dimen name="navigation_bar_height_landscape">48dp</dimen>
<!-- Width of the navigation bar when it is placed vertically on the screen -->
<dimen name="navigation_bar_width">42dp</dimen>
发布于 2016-09-28 19:22:54
尝试此code
Resources resources = context.getResources();
int resourceId = resources.getIdentifier("navigation_bar_height", "dimen", "android");
if (resourceId > 0) {
return resources.getDimensionPixelSize(resourceId);
}
return 0;
https://stackoverflow.com/questions/25603718
复制相似问题