I have an android app that I'm trying to add support for different densities, screen sizes, etc. I've developed the app on the simulator with the HVGA support and used all icons from our iphone app which turns out nice since the resolution was at 320x480. Everything looks good now but I'm a bit confused after reading the official android documentation. For layouts I'm going through and ensuring everything is in dp units but when it comes to the images I'm lost. I know that mdpi is 160 but what do I tell my designer for what the hdpi image needs to be? Do we need to increase the height and width and the dpi? Or is it simply enough to leave the dpi as is and increase the height width? For example, if I have an image that's 100 x 100 with 160 dpi, in order to render it identical on an hdpi screen it should now be 150 x 150 with 240 dpi? Assuming if I leave the dpi at 160 it will just be a little blurred? Sorry about silly question but I just want to make sure I'm doing everything right and I'm really a C developer with no graphics experience at all.... No excuse at all but could use some help. I saw some examples where the splash screen for mdpi was 320x480 at 160 dpi but then the hdpi splash screen was at 480 x 800 at 240. Obviously 480 x 1.5 does not equal 800. Furthermore, after looking at the icons in the android sdk, they only scale up the width and height, not the dpi. Probably because they're icons and don't need to be? Lost in photoshop land....
Why is it problematic to define sizes using pixels on Android? Although screen pixel density varies, this does not impact the use of pixels to define sizes. Large devices always have more pixels, so your UI elements will be e=affected if you define them with pixels.
In 3x screen (~480 DPI) it takes three times as many pixels (264 x 108 PX) to fill the area of 88 x 36 density-independent-pixels. In 4x screen (~640 DPI) it takes four times as many pixels (352 x 144 PX) to fill the area of 88 x 36 density-independent-pixels.
For me as a Graphic Artist of a Mobile Development Company, I made UI's for Android in this dimension:
HDPI : 640px x 960px in 300dpi optimized by 75%
MDPI : 640px x 960px in 300dpi optimized by 50%
LDPI : 640px x 960px in 300dpi optimized by 25%
Take a look at Providing Resources.
There is a section there on "Screen pixel density (dpi)". You are correct that you just scale your width and height for the resources. A 90 pixel image at ldpi becomes a 120 px a mdpi, a 180 at hdpi and a 240 ad xhdpi.
You are also right that the 800 isn't 1.5 x the base 480 height. The reason for that is that these are all approximates based on targets for each density. The phone os lies to the applications running on it about its actual height and width and scales the resources to match the exact dimensions of the handset, since it can vary. This is my understanding.
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