获取整个屏幕的高度(包含顶部状态栏和底部虚拟菜单)

/**
*
* 获取整个屏幕的高度(包含顶部状态栏和底部虚拟菜单)
*/
public int getScreentHeight() { 1280*720
int heightPixels = 0;
WindowManager w = getWindowManager();
Display d = w.getDefaultDisplay();
DisplayMetrics metrics = new DisplayMetrics();
d.getMetrics(metrics);
try {
heightPixels = (Integer) Display.class.getMethod("getRawHeight").invoke(d);
} catch (Exception e) {
Log.e(TAG, "", e);
}
try {
android.graphics.Point realSize = new android.graphics.Point();
Display.class.getMethod("getRealSize", android.graphics.Point.class)
.invoke(d, realSize);
heightPixels = realSize.y;
} catch (Exception e) {
Log.e(TAG, "", e);
}
return heightPixels;
}

posted @ 2013-11-30 15:30  马骝  阅读(807)  评论(0编辑  收藏  举报