7

Which size of an image should be placed in the neutral drawable folder?

I have an icon file in 5 different versions:

  • 24x24 = ldpi
  • 32x32 = mdpi
  • 48x48 = hdpi
  • 64x64 = xhdpi
  • 96x96 = xxhdpi

On the other hand I have 6 different folders:

  • /drawable
  • /drawable-ldpi
  • /drawable-mdpi
  • /drawable-hdpi
  • /drawable-xhdpi
  • /drawable-xxhdpi

5 Files and 6 folders means that either one folder has to stay empty (which one?) or one file has to be used twice?

This is what the docs say:

If no matching resource is available, the system uses the default resource and scales it up or down as needed to match the current screen size and density

The "default" resources are those that are not tagged with a configuration qualifier. For example, the resources in drawable/ are the default drawable resources. The system assumes that default resources are designed for the baseline screen size and density, which is a normal screen size and a medium density. As such, the system scales default density resources up for high-density screens and down for low-density screens, as appropriate.

However, when the system is looking for a density-specific resource and does not find it in the density-specific directory, it won't always use the default resources. The system may instead use one of the other density-specific resources in order to provide better results when scaling. For example, when looking for a low-density resource and it is not available, the system prefers to scale-down the high-density version of the resource, because the system can easily scale a high-density resource down to low-density by a factor of 0.5, with fewer artifacts, compared to scaling a medium-density resource by a factor of 0.75.

OK, that the mdpi version should be placed in drawable-mdpi, ldpi in drawable-ldpi, etc. is out of question. But which version goes to the neutral folder?

Should I place the xxhdpi files there (scale down if no match is found)? What about the -xxhdpi folder than? Keep it empty or place the files there as well?

Andrei Herford
  • 17,570
  • 19
  • 91
  • 225
  • see my ans here :http://stackoverflow.com/questions/19875158/android-background-image-size-in-pixel/19875228#19875228 – Haresh Chhelana Jun 13 '14 at 06:52
  • @Haresh Thanks, but the linked answer is just a list of different sizes for different elements (background, list, etc.). How does this answer the question which size to place in which folder? – Andrei Herford Jun 13 '14 at 07:05
  • You can place XML-drawables, which independent of screen size there. – Ganster41 Jun 13 '14 at 07:08
  • in your case "/drawable" this folder stay empty. – Haresh Chhelana Jun 13 '14 at 07:10
  • Mmmh, if "/drawable" stays empty, how does the system know which file is the default resource? As the docu says the system assumes that the files in "/drawable" are "designed for the baseline screen size and density". Would it not be better to place the mdpi files here and leave the -mdpi folder empty? – Andrei Herford Jun 13 '14 at 07:16

1 Answers1

7

The default /drawable folder expects mdpi images. And mostly used in 2 cases:

  1. To have non-density dependent images. eg: selectors, which indirectly link to images from density named folders again.

  2. To have all the images in only this folder and ignore all the other drawable folders. In which case the images will be scaled depending on the screen density.

For your case:

You can keep only xml files like selectors in the default /drawable folder and other images in their respective folders

Archie.bpgc
  • 23,812
  • 38
  • 150
  • 226