tnblog
首页
视频
资源
登录

Android 获取导航栏的高度

5144人阅读 2020/4/8 9:28 总访问:88139 评论:0 收藏:0 手机
分类: Abp

获取Android手机屏幕的高度

/**
 * 获取状态栏高度 
 * 
 * @param context 上下文
 * @return 高度
 */public static int getStatusBarHeight(Context context) {
    int result = 0;
    int resId = context.getResources().getIdentifier("status_bar_height", "dimen", "android");
    if (resId > 0) {
        result = context.getResources().getDimensionPixelSize(resId);
    }
    return result;}
/**
 * 获取导航栏高度
 *
 * @param context 上下文
 * @return 高度
 */public static int getNavigationHeight(Context context) {
    int resourceId = 0;
    int rid = context.getResources().getIdentifier("config_showNavigationBar", "bool", "android");
    if (rid != 0) {
        resourceId = context.getResources().getIdentifier("navigation_bar_height", "dimen", "android");
        return context.getResources().getDimensionPixelSize(resourceId);
    } else{
        return 0;
    }}


评价
希望你懂得很多之后,依旧热爱生活
排名
6
文章
6
粉丝
16
评论
8
{{item.articleTitle}}
{{item.blogName}} : {{item.content}}
ICP备案 :渝ICP备18016597号-1
网站信息:2018-2024TNBLOG.NET
技术交流:群号656732739
联系我们:contact@tnblog.net
欢迎加群交流技术