Android adaptation solution Summary (1): android adaptation solution Summary

Source: Internet
Author: User

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 .)


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.