In Eclipse's AVD, I've created two devices that are identical except for their density values. Device 1 has has an
abstracted LCD density of 240; device 2 has 160. The resolution for both is 480x800.
Can someone explain to me why elements on device 1's screen looks "bigger"? Since they have the same resolution, shouldn't they be showing the same number of pixels? If anything, since device 1 has a higher density, shouldn't it show more details/screen real estate?
Screeshots - (Click for larger variant)
As shown above, I'm drawing a circle with a radius of 15dp at a random screen position on both devices. The circle is definitely smaller on device 2, as is the action bar. Why is this?
You are drawing with dp, not physical pixels. dp try to abstract from the physical size and give the user a GUI element of the same physical size. So if the pixels on one device are smaller you need to use more physical pixels to obtain the same effect as on a device with bigger pixels.
So: 800 pixel / 240 pixel per inch = 3 1/3 inch (physical length of that screen dimension). Size of one pixel: 1 pixel / 240 pixel per inch = 0,004 inch. 800 pixel / 160 pixel per inch = 5 inch. Size of one pixel: 1 pixel / 160 pixel per inch = 0,006 inch.
So with the same resolution (number of pixels) the pixels in the lower density device are significantilly bigger (around 50% bigger in each dimension). So you need less physical pixel to draw the circle to show the circle with 15 dp.
Simply said: Low dpi means bigger pixel. Same resolution (number of pixel) means lower dpi device has a bigger screen.
So on physical devices these circles have the same physical size on devices with different size. But your emulator windows have the same size, for speed reasons one physical pixel is mapped to one physical pixel on your computer screen. So you are using less pixel on the low dpi device but paint them with same-size physical pixels. Solution: You need to resize the emulator window so it matches the real size. I just don't have access to my Android SDK installation but IIRC you can set the (computer) screen dpi in the AVD launch options so the size will be set automatically.
Here are the images scaled to retain the proportion of the real devices:
As you can see the circles have the same physical size, as have the action bar, the icon and the status bar.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!Donate Us With