1

I'm confused about the values that we use in values/dimens.xml.

For ex. if I've declared the below dimension for text size in values/dimens.xml

<dimen name="text_30">30sp</dimen>

then what should be an equivalent value of 30sp in values-sw600dp/dimens.xml and values-w820dp/dimens.xml ? Is there any proportion/formula that we need to apply while putting values in these different dimens.xml ?

Also same question for dp values as well.

Thanks in advance.

Amrut
  • 2,655
  • 3
  • 24
  • 44
  • from my understanding. Size will be same for all in `values-sw600dp`, `values-sw720dp`, `values-sw820dp`, but it will auto check device wether it is large or small. try it, may its help you – Patel Pinkal Jan 17 '17 at 13:24

1 Answers1

0

You will have to calculate for different devices and that's a lengthy way. you can do something like mentioned here.

TextView text = new TextView(this);
text.setText("text");
text.setTextSize(16 * getResources().getDisplayMetrics().density);

This will always show same text size for all the devices.

Community
  • 1
  • 1
Raheel
  • 181
  • 12