I have created a UI that requires some font adjustment for small screens. From what I understand, in order to achieve such scaling, I must create a “diemen.xml” inside both values-normal and values-small directories.
The syntax seems pretty straight forward but what I dont understand is how does Android know where to get the correct values from. Is there a Java code that needs to be added?
For an exmaple:
android:layout_height="@dimen/textview_height"
How would it know if it’s normal sized screen or small?
Thanks!
Android figures this out automatically when it starts your app on a particular device. If the device configuration is small, it will bind
@dimen/textview_heightto the value invalues-small, etc. You don’t need to provide any Java code for this to happen. The details of how this is done are described in the section How Android Finds the Best-matching Resource of the guide topic Providing Resources. You should also read the document Handling Runtime Changes, which discusses what happens to your app is running when the device configuration changes.