原文转自:http://www.chengyunfeng.com/2010/02/how-to-obtain-the-equipment-the-width-and-height
//在某些场所下可能需要获取手机屏幕的宽度和高度,可以通过如下代码获取:
DisplayMetrics dm = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(dm);
mScreenWidth = dm.widthPixels;
mScreenHeight = dm.heightPixels;
//也可通过getSystemService来获取WindowManager:
WindowManager manager = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE);
Display display = manager.getDefaultDisplay();
Pont screenResolution = new Point(display.getWidth(), display.getHeight());