1

I built an Android tablet application and I'm trying to figure out how to make the system select the correct resources.

I understand the concepts described in the documentation. There are a number of different resource folders for different densities ldpi, mdpi, hdpi, etc... - but is there a way to have the system select resources based on resolution of the device? In the layout folder structure you can specify minimum width with layout-sw600dp. Is there a similar mechanism for resources? There are several devices considered medium density that have different resolutions. Ideally I would like to define resources for resolutions and have more flexibility than just pixel density.

I've also tried to use the built in scaling but it doesn't appear to work with my Nexus 7. Resources that are designed for higher resolutions do not seem to scale down at all. Perhaps I'm doing something wrong.

Thanks.

Londo
  • 1,163
  • 2
  • 8
  • 6

2 Answers2

0

I'm not 100% sure I read your question correctly, but you can suffix any subfolder of the res/ folder with the target specifiers. So not just res/layout-sw600dp, but also res/drawable-sw600dp and res/values-sw600dp. These rules can be combined, so res/values-sw600dp-mdpi will also work.

Also note that the Android SDK Documentation is a bit flaky in this area. The Training section explains a neat trick using resource aliases that helps you avoid copy-pasting layout XML's, but the API Guide and Reference docs never mention it, so it's easily overlooked.

Barend
  • 17,296
  • 2
  • 61
  • 80
  • Makes sense. I tried this at some point, I just didn't have the correct parameters for the device I was testing on, I think. All of the different configurations for Android displays are tricky in the SDK. The Nexus 7 is also said to be 1280x800 but seems to run at 800x1280. I'm not sure if this throws a kink in things. – Londo May 06 '13 at 00:42
0

you can, you can specialize folder name like this, drawable-800x480, but make sure that greater value will become first(800 in this case)

Onur A.
  • 3,007
  • 3
  • 22
  • 37