I need to set all the text content of the application depending on the screen dimensions. I mean buttons, textviews etc... For example, If i execute the app ina Pixel C tablet, the buttons text size and the textviews text size must be very big, and very small in a 320x240 device.
First I tried autoSizeTextType
but finally I discart this approach because it can only be applyed to TextView and not to Buttons, etc...
After that, I tried this approach: https://developer.android.com/training/multiscreen/screendensities creating 4 folders inside res folder:
values-hdpi
values-mdpi
values-xhdpi
values-xxhdpi
And inside them a dimens.xml
file with the text size values, for example, this is the file inside the values-xhdpi
folder:
<resources>
<dimen name="big_text">35sp</dimen>
<dimen name="medium_text">25sp</dimen>
<dimen name="small_text">20sp</dimen>
</resources>
And for the other folders i put different values to test it.
It works... but... is not the behaviour I'm searching for. Why? Because I executed the application in two different xhdpi emulators, the Pixel C and the Nexus 4. Pixel C has bigger resolution, but the screen is super big, so both devices uses the same dimens.xml
file, but the buttons and texts are being displayed small in Pixel C and super big in Nexus 4, as you can see in this picture:
What should I do to get text size value which occupies the same portion of the screen for a phrase in all the devices?