Take the 2-minute tour ×

I didn't really understand the DP measure, even though I've read about it 2 times.

Let's say I have an image it's resolution is: 400 X 400 PX.

And I want to put it as background image to my app. and I'm putting the same image on the different drawable folders(ldpi,mdpi,...)

Would the image strech? I don't know what resolution the image should be on the different drawable folders so it will fit the devices.

share|improve this question
yes it will stretch as per your layout design. –  Padma Kumar Aug 31 '12 at 15:00
@PadmaKumar Can you please explain? I still don't understand how it really goes. –  idish Aug 31 '12 at 15:02
add comment

3 Answers

up vote 3 down vote accepted

Your base density is mdpi. So your 400x400 dp image will be rendered as is on mdpi devices only. If you want the same size on ldpi, you have to scale your image by 0.75. For hdpi your image needs to be 1.5 times bigger and for xhdpi devices, 2.0 times the size of your mdpi.

As mdpi is your base, I always put drawables in res/drawable-mdpi folder while developing. Once I got code ready for release I add hdpi resources to res/drawables-hdpi. I personally do not care ldpi devices as mostly no device I target is lower density than mdpi and if anyone will have such, then I am fine with android framework doing the downscale. But the upscaling is other story - you will always get bad results (blurry images) as you simply cannot technically make bigger bitmap from smaller without artifacts (no, CSI lies ;) - you simply got not enough data so you have to extrapolate. So it's better to provide proper drawables yourself or your end users would complain and your app may look not as nice as it could.

share|improve this answer
add comment

The idea is that the actual physical size of a displayed image will be different depending on the screen resolution.

On a mdpi device, screen density is about 1.5 dpi (dots per inch), which means that your 400px wide image will measure 2.5 inches.

If you want your image to be roughly the same size on a hdpi device (e.g 250 dpi), then you must provide a 625 pixel wide image (2.5*250). You shall put the image in the drawable-hdpi folder.

See this page for the description of the different densities.

share|improve this answer
add comment

There are two important parameters which needs to taken cared when you are designing an app which
should run on multiple devices:

  • size(physical size of the device)
  • density of the device

Size: Size of a device in android is not defined as a unique physical value but as a range.
These are: small, normal, large and xlarge.

Density: Density is also defined as a range.
These are: ldpi, mdpi, hdpi and xhdpi.

enter image description here

For handling size you need to use have multiple layouts, one for each category of the size and you need to use different dp value for the height and width of the views for each of the layout as the sizeof a small and a large device will not be same.

For handling density you need to using different drawables for different screen densities i.e you need to place different density drawables in different drawable folders.
These are the resolutions for a particular drawable

  • 36x36 for low-density (placed in drawable-ldpi)
  • 48x48 for medium-density (placed in drawable-mdpi)
  • 72x72 for high-density (placed in drawable-hdpi)
  • 96x96 for extra high-density (placed in drawable-xhdpi)

The ratio for this variation of the resolution is 3:4:6:8(ldpi:mdpi:hdpi:xhdpi)

For further reading you can refer to this android developer's link:

share|improve this answer
add comment

Your Answer


