android 获取顶部状态栏 信息 高度

来源:互联网 发布:js获取自定义标签的值 编辑:程序博客网 时间:2024/05/22 14:10
/** * 获取状态栏高度 *  * @return */public static int getStatusBarHeight(Context context) {Class<?> c = null;Object obj = null;java.lang.reflect.Field field = null;int x = 0;int statusBarHeight = 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());statusBarHeight = context.getResources().getDimensionPixelSize(x);return statusBarHeight;} catch (Exception e) {e.printStackTrace();}return statusBarHeight;}

0 0