2
votes

I want to create an Android app with ImageButtons that look good, and appropriately-sized, on a wide variety of devices. I'm aware that multiple levels of conditionality can be built into Android drawables, the simplest being to create folders like

drawable-ldpi
drawable-mdpi
drawable-hdpi
drawable-xhdpi

for different densities of bitmap. However, buttons that look good on an mdpi phone look poky on an mdpi tablet, and I'd rather use the hdpi bitmaps for that application. There is a way to do this using folders named like

drawable-small-ldpi
drawable-normal-ldpi
drawable-large-ldpi
drawable-xlarge-ldpi
drawable-small-mdpi
drawable-normal-mdpi ...

etc. As you can see there are sixteen different folders to cover conditional screen sizes for each density. I can probably reduce this somewhat by using defaults like

drawable-ldpi
drawable-large-ldpi
drawable-xlarge-ldpi ...

but my intention is to use the SAME drawables for large and x-large screens on one density as for the small and normal screens on the density above. I feel that this method is a waste of resource space in the APK. Is there a way to create SINGLE drawable folders that contain images targeted for:

  • Small low-density devices
  • Large low-density AND small medium-density devices
  • Large medium-density AND small high-density devices
  • Large high-density AND small extra-high-density devices
  • Large extra-high-density devices?

Alternatively, is there another way to assert conditionality based on device size AND device density?

1

1 Answers

1
votes

Taken from http://developer.android.com/guide/topics/resources/providing-resources.html#AliasResources:

"When you have a resource that you'd like to use for more than one device configuration (but do not want to provide as a default resource), you do not need to put the same resource in more than one alternative resource directory. Instead, you can (in some cases) create an alternative resource that acts as an alias for a resource saved in your default resource directory."