Mikhail Mikhail - 27 days ago 9
Android Question

5.2'' and 5.0'' screen support on android devices

I have been struggling with this problem about a week and can not figure out how to make it work. I have some views on a screen. And one

values\dimens.xml(sw320dp-xxhdpi)
resource file. Also I have
nexus 5.2 1080*1920 420dpi
and
nexus 5.0 1080*1920 xxhdpi
. The layout appears differently on both screens. How to make it display the same on each device?
What resource file should I add (if it is any)?

How to add for example
values\dimens.xml(1080*1920 420dpi)
?


5.2''

5.0''

Answer

I think your layout is simply built as poorly scaling. Unless you have some very specific use case, you need to make sure your layout fills the area it is provided with regardless.

As for the resource folder, if you want to make sure the same layout file is used on large screens, it is enough to put it in the folder layout-sw360dp. If you have xxhdpi devices with the resolution 1080x1920, Android will select the same file for both since the smallest side will be exactly 1080 / 3 = 360 density-independent pixels.