BolbazarMarme
BolbazarMarme

Reputation: 1231

How to arrange dimens.xml for different screen resolutions?

I have 2 test devices namely, Oneplus 3T and Samsung S9. I have created dimens.xml in xxhdpi folder (intended for Oneplus 3T) and xxxhdpi folder (intended for Samsung S9). Frankly, Both devices use dimens.xml from xxhdpi instead. I have tried change the folder into sw400dp-xxhdpi and sw420dp-xxhdpi but still both devices take dimensions from xxhdpi folder instead.

How should I arrange my dimens.xml files such that different dimensions are applied separately for each respective device.

Thanks in advance.

UPDATE

I have managed to remove my xxhdpi folder and define dimens.xml for Oneplus 3T inside folder values-sw360dp NOT values-sw400dp even though specs says that it has 401 ppi. values-sw400dp doesn't work for S9.

UPDATE

It turns out that S9 has 3 choices of display resolution namely, hd, fhd and wqhd. xhdpi works for hd, xxhdpi works for fhd and xxhdpi works for wqhd. Unfortunately, in debug mode, I cannot see the difference.

Upvotes: 3

Views: 698

Answers (1)

IamVariable
IamVariable

Reputation: 456

You have to create multiple dimens.xml file for this case.

values-sw720dp          10.1” tablet 1280x800 mdpi

values-sw600dp          7.0”  tablet 1024x600 mdpi

values-sw480dp          5.4”  480x854 mdpi 
values-sw480dp          5.1”  480x800 mdpi 

values-xxhdpi           5.5"  1080x1920 xxhdpi
values-xxxhdpi           5.5" 1440x2560 xxxhdpi

values-xhdpi            4.7”   1280x720 xhdpi 
values-xhdpi            4.65”  720x1280 xhdpi 

values-hdpi             4.0” 480x800 hdpi
values-hdpi             3.7” 480x854 hdpi

values-mdpi             3.2” 320x480 mdpi

values-ldpi             3.4” 240x432 ldpi
values-ldpi             3.3” 240x400 ldpi
values-ldpi             2.7” 240x320 ldpi

Something like this

Upvotes: 3

Related Questions