0
votes

I am confused by Android documentation about this questions so I will ask them here: I have HTC Desire mobile on this link I see that it has pixels 480×800 and Density 252

  1. When I try to get Density like this getResources().getDisplayMetrics().densityDpi I get value 240 and not 252.
  2. I have image with size 400x113 with Density 240(Pixels/Inch) And when I try to get size in program with getWidth and getHeight it said 600 and 170.
  3. What size my image need to be for this phone HTC Desire and which Density it need to have.

Thanks.

1

1 Answers

2
votes
  1. Android puts devices into buckets: ldpi, mdpi, hdpi, xhdpi. The Desire falls into the hdpi bucket which is 240dpi. As you can see, 252dpi is very close to 240dpi.
  2. The default mdpi is 160dpi. When getting resources, unless you specify otherwise it will try to scale images from the original density to the new one. 160:240::400:600::113:170. You probably put your image in the drawable folder.
  3. This size is fine, but you should put it in the drawable-hdpi folder if it's for hdpi devices. (You should probably also put a mdpi version sized appropriately in the drawable-mdpi folder for mdpi devices too).

Read through this document for details on supporting multiple screens and information on densities.