Android: Provide a resource if width is smaller than specific DP

Viewed 1353

How do I use the resource qualifiers system in Android to specify that I want a resource to apply only if the width is smaller than a particular value?

To elaborate, suppose I want to provide one layout whenever the current available width is up to - say 320dp - and another layout for all other cases. This is what comes to mind:

layout-w320dp/mylayout.xml
layout/mylayout.xml

However, as per my understanding of the resource matching algorithm, even a large device (say, a tablet in landscape) qualifies as w320dp - because, well, the available width would be greater than 320dp.

As such, the resource from layout-w320dp would always be picked - even for larger phones and tablets. The only time the default resource from the layout folder is picked is if the available width is less than 320dp.

So, how do I express a "smaller than" relationship using the Android resource matching system?

2 Answers
Related