System bar size on android tablets

后端 未结 3 1421
旧巷少年郎
旧巷少年郎 2021-02-11 01:58

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

3条回答
  •  醉酒成梦
    2021-02-11 02:51

    // 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;
    }
    

提交回复
热议问题