Reputation: 391
I am using multi support value for dimension , I have given value like this
I have make the value folder like
value
dimen.xml
<dimen name="padding_1">1dp</dimen>
and
values-sw320dp-hdpi
dminen.xml
<dimen name="padding_1">what padding should I give</dimen>
values-sw320dp-xhdpi
dminen.xml
<dimen name="padding_1">what padding should I give</dimen>
values-sw320dp-xxhdpi
dminen.xml
<dimen name="padding_1">what padding should I give</dimen>
values-sw360dp
dminen.xml
<dimen name="padding_1">what padding should I give</dimen>
values-sw480dp
dminen.xml
<dimen name="padding_1">what padding should I give</dimen>
values-sw600dp
dminen.xml
<dimen name="padding_1">what padding should I give</dimen>
values-sw720dp
dminen.xml
<dimen name="padding_1">what padding should I give</dimen>
My question is that what padding dimension should I give so I can support to different different device, like how to find the 1dp for every value folder.
I have go through with this link https://developer.android.com/training/basics/supporting-devices/screens.html
but not understand clearly. I have gone through the Dimenify
plugin as well but not getting clear solution.
Edit I wanted to know is there any way to put exact dimension in all value bucket or any dp converter which convert exact dimension for all value bucket in android
Upvotes: 2
Views: 1761
Reputation: 4947
A few tips to help you go with your answer.
The dp metric lets you define consistent sizes across device densities. This would typically mean they look the exact same size on a majority of devices.
While giving a fixed width works for a few of the cases, visual appeal truly lies in the fact that you can scale down the size of your UI on smaller devices and scale it up on higher devices. You need to start using android's bucketing feature that pulls out different resources based on the device config with the same qualifying name.
Lets say you may choose for eg. to have margins
a margin_normal
maybe visually perfect at 16dp for xxhdpi, but you see that 18dp works for xxxhdpi whereas 14dp works for xhdpi device.
These are subjective values but rest assured scale factors are a good approximation to this rule.
Dimenify deals with this conversion automatically but you need to provide the scale factors by trial and error and as a one time effort.
Upvotes: 0
Reputation: 1646
values folders to create
values-sw320dp,
values-sw480dp,
values-sw600dp,
values-sw720dp. You should create dimens.xml in all the values folders.
values-sw360dp
dimens.xml
<dimen name="padding_1">5dp</dimen>
values-sw480dp
dimens.xml
<dimen name="padding_1">8dp</dimen>
values-sw600dp
dimens.xml
<dimen name="padding_1">10dp</dimen>
values-sw720dp
dminen.xml
<dimen name="padding_1">13dp</dimen>
Based on your requirement you can give padding or any dimen values. As you
given, you should give same name for dimen in all the folders. Android will
automatically pick the dimen value based on your screen size.
Upvotes: 1