text_size in multiple screen support

59 views Asked by At

I'm trying to decrease the text size of a textview depending on the device the app runs. However I can't make it work.

I created the folder values-sw320dp (also tried values-w320dp) and put inside the dimens.xml file

<resources>
<dimen name="text_size">25sp</dimen>
</resources>

and my values/dimens.xml file contains

<dimen name="text_size">18sp</dimen>

What I expect is to load the app in Nexus One (emulator), which is 482 x 320 dp, and get the text size 18sp. However I get text size 25sp.

Does anyone know what is happening?

Thank you

4

There are 4 answers

2
Shoeb Siddique On BEST ANSWER

Create folder as values-hdpi

dimens.xml for values-hdpi

<resources>
<dimen name="text_size">18sp</dimen>
</resources>

And Create folder as values-xhdpi

dimens.xml for values-xhdpi

<resources>
<dimen name="text_size">25sp</dimen>
</resources>

And use like this-

android:textSize="@dimen/text_size"
1
Neal Ahluvalia On

I use values-hdpi, values-mdpi, values-ldpi, values-xlarge

1
Ihor Bykov On

Nexus One has dimension 480 x 800, so try values-sw360dp

1
kalidoss rajendran On

Create folder as values-sw600dp and values-sw720dp in res folder.

dimens.xml for values-sw600dp

<resources>
<dimen name="text_size">4sp</dimen>
</resources>

dimens.xml for values-sw720dp

<resources>
<dimen name="text_size">6sp</dimen>
</resources>