0
votes

Specifications: Samsung Galaxy Ace: LCD TFT / 3.5 inch / 480 x 320 pixels / 164 dpi.

but:

DisplayMetrics metrics = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(metrics);

float V_dpi = metrics.densityDpi;

V_dpi = 160 but technical characteristics is 164.

2

2 Answers

2
votes

The answer is in the documentation for densityDpi:

The screen density expressed as dots-per-inch. May be either DENSITY_LOW, DENSITY_MEDIUM, or DENSITY_HIGH.

In other words: it doesn't contain the actual density value, but rather the bucket in which it fits. Hence, the value will always be one of the following:

DENSITY_LOW = 120;
DENSITY_MEDIUM = 160;
DENSITY_HIGH = 240;
DENSITY_TV = 213;
DENSITY_XHIGH = 320;
DENSITY_XXHIGH = 480;
0
votes

You should use metrics.ydpi and metrics.xdpi I think those values are more accurate.