获取屏幕的真是宽高

Display display = getWindowManager().getDefaultDisplay();
Method mGetRawH = null;
Method mGetRawW = null;
try {
mGetRawH = Display.class.getMethod("getRawHeight");
mGetRawW = Display.class.getMethod("getRawWidth");
rawWidth = (Integer) mGetRawW.invoke(display);
rawHeight = (Integer) mGetRawH.invoke(display);
} catch (NoSuchMethodException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IllegalArgumentException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IllegalAccessException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (InvocationTargetException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

猜你喜欢

转载自zhaweijin.iteye.com/blog/1699284