[Android]通知栏与操作栏的高度-State Bar & Navigation Bar

1.通知栏

public static int getStatusBarHeight() {
        Resources resources = Resources.getSystem();
        int resourceId = Resources.getSystem().getIdentifier("status_bar_height",
                "dimen", "android");
        if (resourceId > 0) {
            return resources.getDimensionPixelSize(resourceId);
        }
        return 0;
    }

 

 

 

2.虚拟键操作栏

    public static int getNavigationBarHeight() {
        Resources resources = Resources.getSystem();
        int resourceId = resources.getIdentifier("navigation_bar_height",
                "dimen", "android");
        if (resourceId > 0) {
            return resources.getDimensionPixelSize(resourceId);
        }
        return 0;
    }

 

posted @ 2014-10-16 21:25  benhero  阅读(527)  评论(0编辑  收藏  举报