如何以编程方式获取Android导航栏的高度和宽度? [英] How do I get the height and width of the Android Navigation Bar programmatically?
本文介绍了如何以编程方式获取Android导航栏的高度和宽度?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
p>
如何以像素为单位获取此UI元素的宽度和高度的大小?
解决方案
请尝试下面的代码:
Resources resources = context.getResources();
int resourceId = resources.getIdentifier(navigation_bar_height,dimen,android);
if(resourceId> 0){
return resources.getDimensionPixelSize(resourceId);
}
返回0;
The black navigation bar on the bottom of the screen is not easily removable in Android. It has been part of Android since 3.0 as a replacement for hardware buttons. Here is a picture:
How can I get the size of the width and the height of this UI element in pixels?
解决方案
Try below code:
Resources resources = context.getResources();
int resourceId = resources.getIdentifier("navigation_bar_height", "dimen", "android");
if (resourceId > 0) {
return resources.getDimensionPixelSize(resourceId);
}
return 0;
这篇关于如何以编程方式获取Android导航栏的高度和宽度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文