DisplayMetrics metric = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(metric);
int width = metric.widthPixels; // 宽度(PX)
int height = metric.heightPixels; // 高度(PX)
float density = metric.density;
//160表示1.0 mdpi;240表示1.5 hdpi;320表示2.0 xhdpi以此类推
int
densityDpi = metric.
densityDpi
;
Log.d(TAG, "width:"+width);
Log.d(TAG, "height:"+height);
Log.d(TAG, "destiny:"+density);
Log.d(TAG, "densityDpi:"+densityDpi);