Android顶部状态栏和底部导航栏高度计算

来源:互联网 发布:微积分中d含义,知乎 编辑:程序博客网 时间:2024/05/17 02:14

项目开发中,经常会遇到界面适配的问题,状态栏和导航栏的高度计算,直接影响着App的展示效果,下面就来看一下两种控件高度是如何计算的。

1, 顶部状态栏(status bar)

private int getStatusBarHeight() {    Resources resources = mActivity.getResources();    int resourceId = resources.getIdentifier("status_bar_height", "dimen","android");    int height = resources.getDimensionPixelSize(resourceId);    Log.v("dbw", "Status height:" + height);    return height;}

2, 底部导航栏(navigation bar)

private int getNavigationBarHeight() {    Resources resources = mActivity.getResources();    int resourceId = resources.getIdentifier("navigation_bar_height","dimen", "android");    int height = resources.getDimensionPixelSize(resourceId);    Log.v("dbw", "Navi height:" + height);    return height;}
阅读全文
0 0
原创粉丝点击