状态栏相关

public static int getStatusBarHeight(Context context) {
        if (statusbarheight == 0) {
            try {
                Class c = Class.forName("com.android.internal.R$dimen");
                Object o = c.newInstance();
                Field field = c.getField("status_bar_height");
                int x = (Integer) field.get(o);
                statusbarheight = context.getResources().getDimensionPixelSize(x);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        return statusbarheight;
    }

你可能感兴趣的:(状态栏相关)