如何获得的导航栏的高度和宽度编程 [英] How to get height and width of navigation bar programmatically

查看:107
本文介绍了如何获得的导航栏的高度和宽度编程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在屏幕底部的黑色导航栏是不容易移动在Android中,它已经3.0作为替换为硬件按钮是Android的一部分。

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.

就在此处显示的照片。

我怎样才能在像素这个UI元素的宽度和高度的大小?必须有一些code这一点。任何想法?

how can I get the size of the width and height of this UI element in pixels? There has to be some code for this. Any ideas?

推荐答案

尝试下面code:

Resources resources = context.getResources();
int resourceId = resources.getIdentifier("navigation_bar_height", "dimen", "android");
if (resourceId > 0) {
    return resources.getDimensionPixelSize(resourceId);
}
return 0;

这篇关于如何获得的导航栏的高度和宽度编程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆