Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Emulator HDPI vs. MDPI vs. LDPI

Starting android emulators with the same resolution of 480x800 at different DPIs (120, 160, 240), I would think that the screen with the highest DPI would have the smallest interface elements (images, buttons, etc) and the one with the lowest DPI would have the largest. But exactly the opposite is true. I've included a screen shot to demonstrate what I mean.Right to left: HDPI emulator, MDPI emulator, LDI emulator

My emulator settings are:

HDPI:

  • Skin resolution: 480x800
  • Abstracted LCD Density: 240

MDPI:

  • Skin resolution: 480x800
  • Abstracted LCD Density: 160

LDPI:

  • Skin resolution: 480x800
  • Abstracted LCD Density: 120

I started each of the emulators with the following settings:

  • Scale display to real size
  • Screen size: 5 inches
  • Monitor dpi: 105
  • Scale: 0.56

Am I doing something wrong, or is this the expected result? If it is, why does it behave in this way? If I do the equivalent in Photoshop (view for print option), I get the exact opposite and correct results.

like image 483
Mirkules Avatar asked Dec 22 '22 10:12

Mirkules


1 Answers

The problem turns out to be simple math. If we take the formula for calculating DPI as

dpi = sqrt(height^2 + width^2)/(screen size in inches)

it becomes apparent that you cannot choose all three components when running an emulator -- only two, and android will calculate the missing component.

From my original question above, I was specifying a constant resolution (480x800) and a constant screen size (5 inches). But 480x800 always produces a DPI of roughly 186 dpi. So forcing the DPI to be different in each of these cases confused the Android emulator, and I think it discarded my specified original resolution and calculated its own.

like image 197
Mirkules Avatar answered Dec 28 '22 06:12

Mirkules