I’m developing an app which has different layout and value files for various screens, then I meet a problem: The smallestWidth qualifier only checks if the device smallestWidth is GREATER than indicated value.
This is troublesome when I have below folder structure:
res/layout-port-mdpi
res/layout-sw720dp
res/layout-sw720dp-port
res/layout-sw720dp-land
In this case, on a mdpi sw720 port device, Android will use res/layout-port-mdpi rather than res/layout-sw720dp-port which I really want to use. The res/layout-port-mdpi is for smaller phones.
Is there a way to indicate smallestWidth LESS than like 719dp, or should I need to create res/layout-sw720dp-port-mdpi and for all other dpis? It sounds so stupid.
Thank you for the kind answer.
No, it is not. It is for portrait devices with medium density screens. It stipulates nothing with respect to size.
No.
-sw720dpis a stronger criterion than is-mdpi, so for a device that is-sw720dpand-mdpiand is held in portrait,res/layout-sw720dp-portshould be used.Not really. Android will use a resource set that does not have any
-swNNNdpvalue if the device’s value is lower than any such resource set you use.No.
For example, if your objective is to have some layouts used specifically for
-sw720dpdevices and other layouts used for smaller devices, with some different layouts for landscape for each size, your directories would be:res/layout-sw720dp-land/for-sw720dpdevices in landscape orientationres/layout-sw720dp/for-sw720dpdevices not in landscape orientationres/layout-land/for smaller than-sw720dpdevices held in landscaperes/layout/for smaller than-sw720dpdevices not in landscape orientationHave one of every layout in
res/layout/, and override those layouts in resource sets with more constraints only where needed.