It is completely fine to have more than one variant. The recommendation is to start with anchors and designer script before adding more variants. Variants are difficult to maintain.
The algorithm chooses the variant that its width and height are closest to the normalized device screen size.
- It penalizes variants that are taller or wider than the screen size.
- It prefers variants with the same orientation and variants with the same scale (though you should always use a scale of 1.0).
Hi Erel,
I'm intrigued by how the algorithm works also.
In a project I have 4 variants as below
320x480 scale 1 (160DPI)
480x320 scale 1 (160DPI)
1280x800 scale 1 (160DPI)
800x1280 scale 1 (160DPI)
I was testing the layouts using Nox. Initially my screen size was set to 1280x800 DPI 240 in Nox, but my app was displaying the 480x320 variant.
At 1280x800 DPI 200 it still displays the 480x320 variant.
At 1280x800 DPI 190 it displays the 1280x800 variant.
Another test I tried, my display setting is 1280x800 DPI 240, so the 480x320 scale 1 layout is being used. I removed the 480x320 layout, and the 320x480 layout is used rather than the 1280x800 - so something is being giving higher priority than the orientation, which I would assume was the most important factor in deciding on a layout.
I just tried removing the 320x480 layout, screen at 1280x800 DPI 240 and it isn't using a layout at all.