Android screen adaptation, Android
To sum up your screen adaptation experience, I only hope that I can continue to improve and improve. If you have a warm-hearted "predecessors" to guide me, I am very grateful!
Android 5.0 has already come out, saying that this version has done a lot of work on Android screen adaptation. However, for people with chronic issues like me, I still have to wait patiently. There have been many resolutions before Android, at the beginning of Android, the headers were all big, but I had accumulated some experience in screen adaptation. Here I will summarize it.
1. Use resource ID
1. Resolution (density) identifier adaptation
There are four categories of Android resolutions. I don't know if there will be more in the future. However, when the resolution reaches a certain threshold, it won't be able to be distinguished by future users, after all, on a cell phone screen that is so small, it is useless to be meticulous.
Low Resolution: lhdp (120dp)
Normal resolution: mdp (160dp)
High Resolution: hdp (240dp)
Ultra High Resolution: xhdp (320dp)
Super Resolution
Different Resolutions mainly affect the display of Android mobile phones. If a color or vector background does not affect the display, for example, when a view background is directly created using a color or a drawable that defines an xml type, some of the techniques used in combination with the layout will not be affected by the resolution. To sum it up, use the following resource identifier to provide multiple dimensions for the image:
After a resource identifier is connected to res/drawable with a short line, for example:
Res/drawable-lhdp/: 75% of the normal image size
Res/drawable-hdp/: 100% of the normal image size
Res/drawable-hhdp/: 150% of the normal image size
Res/drawable-xhdp/: 200% of the normal image size
Res/drawable-xhdp/: 300% of the normal image size
Just like the app startup image, you should also set multiple resolution types, which will be 36*36 (pixels), 48*48 (pixels), 72*72 (pixels ), 96*96 (pixels), 144*144 (pixels) icons are placed in the corresponding project file directory to achieve different resolutions and display the corresponding images.
2. Size Resource Identifier adaptation
Small: 426*320 (dp)
Normal: 470*320 (dp)
Large: 640*480 (dp)
Xlarge: 960*720 (dp)
Xxlarge?
3. Limited platform identifiers
V4
V9
V11
V14
...
4. Horizontal and vertical screen identifiers
Land
5. exact limits
W <N> dp: precise width resolution
H <N> dp: precise height resolution
Sw <N> dp: The layout file under the layout folder is loaded only when the minimum bandwidth of the device's short side is N. Your device is X in resolution, then this apk installed on your device will load the layout file in the layout-sw480dp.
The above identifiers are usually used in drawable, layout, and values under the res file directory, for example: layout-550dp-large; drawable-large-mdpi; values-1134*720 (large numbers are placed after decimal places)
In addition, add AndroidManifest. xml
<Supports-screens
Android: anyDensity = "true"
Android: largeScreens = "true"
Android: normalScreens = "true"
Android: smallScreens = "true"
Android: xlargeScreens = "true"/>
In addition to the Resource Identifier limitation above, if you want more precise settings, you can use dimen in values. if the requirements are not very strict, you can combine Relativeyout, LinearLayout, also, FrameLayout, which is easy to ignore, uses match or wrap when setting the width and height of the view (android: layout_width = "" android: layout_height =, then set layout_margin = "" or padding = "" to control the distance.
2. Units supported by Android
1. Unit
Px: pixel
In: inches
Mm: mm
Pt: lb (1/72) inch
Dp: pixels irrelevant to px
Dip: dp
Sp: pixel irrelevant to the scale. Similar to dp, it can be scaled based on the user's font size preference.
2. unit conversion
Under the standard resolution (160dp:
1dp = 1dip = 1px
1pt = 160/72 sp
1pt = 1/72 inch