Reputation: 3941
This seems like a bug but maybe I'm doing something really silly and just can't see it. I have these value files:
The integer value files are behaving as expected. Inside the default integers.xml I have:
<integer name="card_item_columns">2</integer>
and for the integers.xml(w840dp) I have:
<integer name="card_item_columns">3</integer>
But when it comes to the dimens files, only the sw600dp one seems to do anything. For the dimens.xml(sw600dp) I have this:
<dimen name="card_width">264dp</dimen>
and for the dimens.xml(w840dp) I have this:
<dimen name="card_width">400dp</dimen>
If I use a Nexus 7 emulator device in portrait it shows 2 columns. When I rotate it I see 3 columns as expected. This proves that it's at least 840dp wide as that integers.xml(w840dp) file is the only place it can get 3 columns from.
However if it's w840dp why doesn't it use the card width value in the dimens.xml(w840dp)? Is this not possible? Can a "w" qualifier not override an "sw" qualifier? I think it should.
I can adjust the value in the sw600dp file and the change is reflected, showing that it's getting called correctly from the layout file.
What basic concept am I not getting here? I find it hard to believe that there is a bug here. Surely if there was, other people would have noticed it. Spot the silly error to get some points. Or give me a clue that leads to the solution. Thanks.
Upvotes: 0
Views: 658
Reputation: 12121
The documentation on the Android site regarding resource qualifier precedence is pretty comprehensive: Providing Alternate Resources
All other things being equal, smallestWidth has higher precedence than Available width
Configuration | Qualifier value
smallestWidth | sw<N>dp
Available width | w<N>dp
Upvotes: 1