How does the Android font size adapt to the change in resolution at different resolutions?
Suppose you need to adapt to 320x240,480x320 resolution. Create a new folder under the Res directory values-320x240, values-480x320. Then in the folder values, values-320x240 and values-480x320 new XML file Dimens.xml, the XML file content is as follows:
<?xml version= "1.0" encoding= "Utf-8"?>
<resources>
<dimen name= "Btntextsize" >14dip</dimen>
</resources>
For different resolutions, the value of the btntextsize is different. In the layout file, reference the value in the following way:
<textview android:layout_width= "Fill_parent"
android:layout_height= "wrap_content" android:gravity= "center"
Android:id= "@+id/lblset" style= "@style/btntext" android:textsize= "@dimen/btntextsize" >
</TextView>
This way, you can easily set the size of the font at different resolutions. Of course, not only the font size, width and other properties of the other, but also can be set in a similar way
Layout to set the image adaptive size, and set the maximum width height, when the width of the picture is greater than the maximum value set, the width of the high value is the maximum value set.
<imageview android:id= "@+id/image_view"
Android:layout_width= "Wrap_content"
android:layout_height= "Wrap_content"
Android:adjustviewbounds= "true"
Android:maxwidth= "42DP"
android:maxheight= "42DP"
Android:scaletype= "Fitcenter"
android:layout_marginleft= "3DP"
android:src= "@drawable/icon"
/>
How to make Android fonts self-adapting to screen resolution