In different resolutions, how does the font size of Android adapt to resolution changes?
Assume that the resolution is 320x240,480 x320. Create a folder values-320x240, values-480x320 under the res directory. Then create the XML file dimens. xml under the folder values, values-320x240, and values-480x320. The content of the XML file is as follows:
| 1234 |
XML version = "1.0" encoding = "UTF-8" ?> resources > dimen name = " btntextsize " 14dip dimen resources > |
For different resolutions, Btntextsize values are different. Reference the value in the layout file as follows:
| 1234 |
< 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 method makes it easy to set the font size at different resolutions. Of course, you can set the font size, width, and other attributes in a similar way.
Set the adaptive size of the image in layout and set the maximum width and height. When the image width is greater than the maximum value, the high value of the width is the maximum value.
[XHTML] View plaincopyprint?
-
- <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"
-
- />
<Imageview Android: Id = "@ + ID/image_view" <br/> Android: layout_width = "wrap_content" <br/> Android: layout_height = "wrap_content" <br/> Android: adjustviewbounds = "true" <br/> Android: maxwidth = "42dp" <br/> Android: maxheight = "42dp" <br/> Android: scaletype = "fitcenter" <br/> Android: layout_marginleft = "3dp" <br/> Android: src = "@ drawable/icon" <br/>
KeyCode:
Android: layout_width = "wrap_content"
Android: layout_height = "wrap_content"
Android: adjustviewbounds = "true"
Android: maxwidth = "42dp"
Android: maxheight = "42dp"