android 得到状态栏高度

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_34206863/article/details/85755236
	private int getStatusBarHeight() {
        Class<?> c = null;
        Object obj = null;
        Field field = null;
        int x = 0;
        try {
            c = Class.forName("com.android.internal.R$dimen");
            obj = c.newInstance();
            field = c.getField("status_bar_height");
            x = Integer.parseInt(field.get(obj).toString());
            return getResources().getDimensionPixelSize(x);
        } catch (Exception e1) {
            Log.d("getStatusBarHeight", "get status bar height fail");
            e1.printStackTrace();
            return 75;
        }
    }

nothing to do

猜你喜欢

转载自blog.csdn.net/qq_34206863/article/details/85755236
今日推荐