Search code examples
androidxmlresourcesdrawablequalifiers

Android XML: Why can't we type @drawable-mdpi, and instead, we must type @drawable?


I see the folders:

drawable-hdpi
drawable-mdpi
drawable-ldpi

I have seen countless threads of "Type @drawable/some_image.png" and "Create a drawable folder in res."

But never did I see a question about XML referring to any drawable folders with qualifier names. Or basically writing XML to refer to any folders with qualifier names.

Why is this not documented? Why XML can't refer supported resource directory names with qualifiers? Is it because of the limitation of XML when it comes to hyphens?

I'm just a newbie. I'm just asking. No big deal about it, I'm just being curious. Thanks for answering.


Solution

  • It is done that way to support multiple screen sizes/resolutions.

    You put the same image (with the same name) in the various folders, modified to look best for that resolution (usually different pixel densities). When there is a call for that image name, the system then goes through those folders and picks the best image (of those you've supplied) for the screen resolution for the device that is being used.