首页 > 移动平台 > 详细

Android获取系统顶部状态栏(StatusBar)与底部工具栏(NavigationBar)的高度

时间:2014-12-04 15:30:22      阅读:259      评论:0      收藏:0      [点我收藏+]

Android一些设备都有上下两条bar,我们可以获取这些bar的信息。下面放上获取高度的代码。代码注释和其他方法有空再放。

原文地址http://www.cnblogs.com/rossoneri/p/4142962.html

获取顶部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;
}

获取底部 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;
}

 

Android获取系统顶部状态栏(StatusBar)与底部工具栏(NavigationBar)的高度

原文:http://www.cnblogs.com/rossoneri/p/4142962.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!