0

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 Answers2

2

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;
MH.
  • 45,303
  • 10
  • 103
  • 116
0

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

Sipka
  • 2,291
  • 2
  • 27
  • 30