Rohit Deshmukh
Rohit Deshmukh

Reputation: 170

How to differentiate dimens for two different DPI

I am using Pixel which has 420dpi density and Moto x4 which has a density of 480dpi density. Both use same value folder i.e. values-xxhdpi.

But, the layout gets large on Moto x4. Is there any way to differentiate different dimens folder?

Upvotes: 1

Views: 111

Answers (1)

Levon Petrosyan
Levon Petrosyan

Reputation: 9655

Mostly you can use

smallest width dp: the smallest width available for application layout in “dp” units; this is the smallest width dp that you will ever encounter in any rotation of the display.

To create one right click on res >>> new >>> Android resource directory

From Available qualifiers window move Smallest Screen Width to Chosen qualifiers

In Screen width window just write the "dp" value starting from you would like Android Studio to use that dimens.

Than change to Project view,right click on your new created resource directory

new >>> Values resource file enter a new file name dimens.xml and you are done.

Upvotes: 1

Related Questions