// get screen dimensions in pixels
Display display = mWindowManager.getDefaultDisplay();
Point size = new Point();
display.getSize(size);
int width = size.x;
int height = size.y;
方法 1
// get screen dimensions in pixels
DisplayMetrics displaymetrics = new DisplayMetrics();
mWindowManager.getDefaultDisplay().getMetrics(displaymetrics);
int width = displaymetrics.widthPixels;
int height = displaymetrics.heightPixels;