Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 487
Andrei Herford Avatar asked Jun 13 '14 06:06

Andrei Herford


1 Answers

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

like image 65
Archie.bpgc Avatar answered Oct 07 '22 05:10

Archie.bpgc