在Android平板电脑系统的小型 [英] System bar size on android tablets

查看:166
本文介绍了在Android平板电脑系统的小型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有我需要的Andr​​oid平板电脑的系统栏的高度问题。这是同样的问题,因为在这里,但我不能用这个答案,因为它给箱尺寸相同从DisplayMetrics。在这两个方面,我得到这个酒吧媒体链接计算的决议。 (这个问题犯规出现在我的智能手机,只是在我的平板电脑)。

解决方案

  //状态栏(位于屏幕的的Nexus设备上的顶部)
公共静态INT getStatusBarHeight(上下文的背景下){
    资源资源= context.getResources();
    INT RESOURCEID = resources.getIdentifier(status_bar_height,地扪,机器人);
    如果(RESOURCEID大于0){
        返回resources.getDimensionPixelSize(RESOURCEID);
    }
    返回0;
}

//导航栏(在屏幕的一个的Nexus设备上的底部)
公共静态INT getNavigationBarHeight(上下文的背景下){
    资源资源= context.getResources();
    INT RESOURCEID = resources.getIdentifier(navigation_bar_height,地扪,机器人);
    如果(RESOURCEID大于0){
        返回resources.getDimensionPixelSize(RESOURCEID);
    }
    返回0;
}
 

I've got the problem that I need the height of the android tablet system bar. It's the same problem as over here, but I cant use this answer, because it gives me the same size as from the DisplayMetrics. At both ways I get the resolution with this bar allready calculated in it. (This problem doesnt appear at my smartphone, just on my tablet).

解决方案

// status bar (at the top of the screen on a Nexus device) 
public static int getStatusBarHeight(Context context) {
    Resources resources = context.getResources();
    int resourceId = resources.getIdentifier("status_bar_height", "dimen", "android");
    if (resourceId > 0) {
        return resources.getDimensionPixelSize(resourceId);
    }
    return 0;
}

// navigation bar (at the bottom of the screen on a Nexus device)
public static int getNavigationBarHeight(Context context) {
    Resources resources = context.getResources();
    int resourceId = resources.getIdentifier("navigation_bar_height", "dimen", "android");
    if (resourceId > 0) {
        return resources.getDimensionPixelSize(resourceId);
    }
    return 0;
}

这篇关于在Android平板电脑系统的小型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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