Android adaptation solution Summary (1): android adaptation solution Summary
Introduction of related measurement units:
Px: The pixel of the screen. Different devices display the same effect.
In: inch (1 inch equals 2.54)
Mm: mm
Pt: LB, 1/72 inch
Dp: device independent pixels (device independent pixel). Different devices have different display effects.
Hardware. The abstract unit based on density. If a screen is 160dpi, 1dp = 1px. (160dpi indicates 1 inch
With 160 pixels)
Dip: equivalent to dp, so we use dp in xml to have the same effect as dip.
Sp: scaled pixels, similar to dp, but also scales according to the user's font size preference.
Dpi: dots per inch, the number of pixels per inch.
Density: what we usually mention on the Android platform is not the screen density, but the pixels per inch and 160 dpi.
(A standard set by google.
The value of densityDpi indicates the number of pixels per inch, in dpi.
Relationship between dip and px:
QVGA densityDpi = 120 Density = 0.75 1dp = 0.75px ldpi
HVGA densityDpi = 160 Density = 1 1dp = 1 pxmdpi
VGA densityDpi = 160 Density = 11dp = 1px mdpi
WVGAdensityDpi = 240 Density = 1.51dp = 1.5 p xhdpi
WQVGA densityDpi = 320 Density = 2 1dp = 2 pxxhdpi
Resource folder match:
By default, Android uses density to match resources:
When the screen density is 2, use resources in the drawable-xhdpi folder
Use resources in the drawble-hdpi folder when the screen density is 1.5
When the screen density is 1, use resources in the drawble-mdpi folder.
When the screen density is 0.75, use resources in the drawable-ldpi folder.
(Although the pixel density of Android devices follows the ratio of 0.75: 1.0: 1.5: 2.0, some devices on the market are incomplete.
In the above four cases, there may be two: for example, 1.33. In this case, you can use resources in the drawable-tvdpi folder .)