20

I have an image with dimensions 250*70 pixels under drawable folder (I'm just starting out in Android development, so i created drawable folder in res) and I have the same image with higher dimensions in drawable-large folder; but the image is not looking as I expected.

Can anyone explain the reason behind/purpose of 3 drawable folders?

Where should I store my image so that it displays properly in both modes (landscape & portrait) and in all the mobiles (including tablets)?

I want my image to scale dynamically to the size of the device screen.

Can anyone share your views or links to search ?

lucian.pantelimon
  • 3,673
  • 4
  • 29
  • 46
SANDHYA
  • 771
  • 7
  • 18
  • 27
  • you should read [this](http://developer.android.com/guide/practices/screens_support.html#qualifiers)... – C. Leung May 09 '12 at 13:51

6 Answers6

31

The folder names need to be :

  • /drawable-ldpi For low density screens
  • /drawable-mdpi For medium density screens
  • /drawable-hdpi For high resolution screens
  • /drawable-xhdpi For extra high resolution screens

/drawable should be reserved for assets that you either (1) don't care about which device or for (2) xml drawable assets

Then on top of that you can provide different resources based on configuration by using config qualifiers, you can read all about it here http://developer.android.com/guide/topics/resources/providing-resources.html

for instance, you can have high resolution assets for landscape with a folder

  • /drawable-land-hdpi

Hope that helps

Stemado
  • 599
  • 5
  • 10
Ian Warwick
  • 4,774
  • 3
  • 27
  • 27
16

By default Android maintain three folders for the images with different resolution reason behind it is the use or the resolution of the Android Device on which the application gonna execute.

hdpi image folder maintain images for the Android Broad Screen set or Android Phones with the Higher resolution.

ldpi for Lower images quality which supports by the earlier sets of the android

mdpi for medium images support xhdi images folder for devices with maximum resolution.

Android OS select the image it self by checking the compatible device and its resolution.

Hope it helps. Accept if you get your explanation.

user1160020
  • 234
  • 1
  • 2
  • 7
  • can I put all images into the same folder, but give them the appropriate endings ? like xxx_ldpi.png, xxx_mdpi.png, xxx_hdpi.png, ...... – sami_analyst Jan 11 '17 at 17:05
7

drawable-ldpi

drawable-mdpi

drawable-hdpi

drawable-xhdpi

drawable-tvdpi

drawable-nodpi

drawable-xxhdpi

drawable-xxxhdpi

We can also use "drawable-xxhdpi"
xxhdpi (480dpi, Android 4.1 or later)

Refer "Android Tabular Column" in the following link

http://en.wikipedia.org/wiki/Smartphone

Please refer "Table 1" in the following link (xxxhdpi)

http://developer.android.com/guide/practices/screens_support.html#xxxhdpi-note

Note: the drawable-xxxhdpi qualifier is necessary only to provide a launcher icon that can appear larger than usual on an xxhdpi device. You do not need to provide xxxhdpi assets for all your app's images.

Note will be in the following link http://developer.android.com/design/style/iconography.html#xxxhdpi-launcher

Sakthimuthiah
  • 2,606
  • 6
  • 26
  • 41
  • These days everyone's min sdk target is 15 or greater, which means ldpi, mdpi and hdpi folders aren't even looked at. My suggestion is to exclude drawables in these folders. Really, unless you have very small-tiny-detailed assets, you can get away with only placing drawables in xhdpi and save yourself some space. – portfoliobuilder Jun 29 '15 at 18:59
  • If user wants to save space then user can use "Nine Patch" images. Because this will save a lot of space – Sakthimuthiah Jun 30 '15 at 13:03
1

You should use drawable-hdpi folder instead of drawable-large.

Also Supporting Multiple Screens page may be helpful for you

Oguz Ozkeroglu
  • 3,025
  • 3
  • 38
  • 64
  • if you have a phone thats xhdpi loading an image 100px wide at 320 dpi, that image at mdpi (160) is 50px right? if my phone is xhdpi and my tablet is mdpi, then how do I get an image to appear larger if the screen density is lower? Do I need two image.png's? image_phone.png and image_tablet.png? Would I store this in drawable - xlarge - mdpi? If so, wouldn't this mean I would need nearly 32 folders in order to support mdpi,hdpi,xhdpi,xxhdpi,small,normal,large,xlarge (3.2 below), and sw320dp, sw480dp, sw600dp, sw780dp? Where am I going wrong? – cjayem13 Sep 11 '14 at 04:39
1

actually there are 4 screen resolution standards - check this link for more information http://developer.android.com/guide/practices/screens_support.html , the table below. When you install your app on device, the device return one of these standards and pick the resources from the corresponding folder - ldpi, mdpi, hdpi and xhdpi

mihail
  • 2,173
  • 19
  • 31
0

1) The reason behind the different drawable folders - to enhance user experience when using our app, by accomodating each device's screen density.

2) "Where should I store ..." - ideally, you store an image with the appropriate size for each screen density that exist. If you are a beginner, just use one folder and don't worry about it now.

4) Image scaling Here's a cool guide that helps you with image scaling inside the app: https://thoughtbot.com/blog/android-imageview-scaletype-a-visual-guide

3) Links: https://material.io/tools/devices/ - list of all devices and densities

Dave Powers
  • 2,051
  • 2
  • 30
  • 34
Maksym
  • 9
  • 1
  • 3