DisplayMetrics metric = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(metric);
float density = metric.density;
int densityDpi = metric.densityDpi;
// 屏幕宽度(像素)
int width = metric.widthPixels;
// 屏幕高度(像素)
int height = metric.heightPixels;
TextView tv = (TextView) findViewById(R.id.textView);
tv.append("density = " + density + "\n");
tv.append("densityDpi = " + densityDpi + "\n");
tv.append("width = " + width + " height = " + height + "\n");
Android Icon Size and Location for Apps
DENSITY | SIZE | LOCATION | RATIO | SCREEN | MARGIN |
---|
XXXHDPI | 192×192 | drawable-xxxhdpi | 4 | 640 DPI | 12 to 16 pixels |
XXHDPI | 144×144 | drawable-xxhdpi | 3 | 480 DPI | 8 to 12 pixels |
XHDPI | 96×96 | drawable-xhdpi | 2 | 320 DPI | 6 to 8 pixels |
HDPI | 72×72 | drawable-hdpi | 1.5 | 240 DPI | 4 to 6 pixels |
MDPI | 48×48 | drawable-mdpi | 1 | 160 DPI | 3 to 4 pixels |
MDPI | 48×48 | drawable (Cupcake) | 1 | 160 DPI | 3 to 4 pixels |
LDPI | 36×36 | drawable-ldpi | 0.75 | 120 DPI | 2 to 3 pixels |
NA | 512×512 | Google Play | NA | NA | As required |