现在的位置: 首页 > 综合 > 正文

简单记录,获取状态栏高度

2013年09月08日 ⁄ 综合 ⁄ 共 375字 ⁄ 字号 评论关闭

一个有效的获取状态栏高度的方法,很早之前找的了,记录在此。(原地址找不到了)

	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) {
			e1.printStackTrace();
			Log.e(TAG, "getbarheight error");
			return 46;
		}
【上篇】
【下篇】

抱歉!评论已关闭.