1

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.

tom_mai78101
  • 2,383
  • 2
  • 32
  • 59

2 Answers2

3

Because resources in hdpi, mdpi, ldpi will use the same Resource ID.

The os determine the device which resource will be use.

Changwei Yao
  • 13,051
  • 3
  • 25
  • 22
  • So, it's the same thing as /res/layout-port and /res/layout-land? I just call on "@layout" and the OS helps me determine which layout I should use according to the user's current orientation? – tom_mai78101 May 12 '12 at 21:32
3

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.

Barak
  • 16,318
  • 9
  • 52
  • 84