83

I was working on Android 1.5, but I have now moved to the latest version. So there is only one "drawable" folder in Android 1.5, but now there are three different folders for storing images in the Android project.

And I have found some articles for these three folders that says

  1. hdpi means High-dpi
  2. mdpi means medium-dpi
  3. ldpi means low-dpi

But what is the exact purpose of these three folders and when should I use a particular folder to store images in?

Peter Mortensen
  • 28,342
  • 21
  • 95
  • 123
Paresh Mayani
  • 122,920
  • 69
  • 234
  • 290

2 Answers2

27

To declare different layouts and bitmaps you'd like to use for the different screens, you must place these alternative resources in separate directories/folders.

This means that if you generate a 200x200 image for xhdpi devices, you should generate the same resource in 150x150 for hdpi, 100x100 for mdpi, and 75x75 for ldpi devices.

Then, place the files in the appropriate drawable resource directory:

MyProject/
    res/
        drawable-xhdpi/
            awesomeimage.png
        drawable-hdpi/
            awesomeimage.png
        drawable-mdpi/
            awesomeimage.png
        drawable-ldpi/
            awesomeimage.png

Any time you reference @drawable/awesomeimage, the system selects the appropriate bitmap based on the screen's density.

Peter Mortensen
  • 28,342
  • 21
  • 95
  • 123
Neha Mangla
  • 1,022
  • 2
  • 13
  • 24
  • 6
    Just an addendum - the [recommended] ratio between ldpi, mdpi, hdpi and xhdpi is 3:4:6:8. That explains how the image values in the answer came about. – kehers Sep 14 '13 at 18:48
0

I got one good solution. Here I have attached it as the image below. So try it. It may be helpful to you...!

Enter image description here

Peter Mortensen
  • 28,342
  • 21
  • 95
  • 123
jigar
  • 1,423
  • 5
  • 23
  • 46