第一种:
Point outSize = new Point();
getWindowManager().getDefaultDisplay().getRealSize(outSize);
int x = outSize.x;
int y = outSize.y;
Log.w(TAG, "x = " + x + ",y = " + y);
//x = 1440,y = 2960
第二种:
DisplayMetrics outMetrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getRealMetrics(outMetrics);
int widthPixel = outMetrics.widthPixels;
int heightPixel = outMetrics.heightPixels;
Log.w(TAG, "widthPixel = " + widthPixel + ",heightPixel = " + heightPixel);
//widthPixel = 1440,heightPixel = 2960