Various scale units in Android development

Source: Internet
Author: User

Px

Pixel (pixel), which represents a physical pixel point on the screen
It is not recommended to use the px drawing UI directly, because the px actual size displayed on different phones will be different for the UI drawn for units affected by pixel density

DP (used to define the size of the control)

Density-independent pixels. One of the virtual pixel units that Android recommends is to have the same effect on a device with a defined UI layout at a different pixel density.

Pixel density dpi = number of pixels per inch length = Screen portrait (landscape) Length/Number of screen portrait (landscape) pixels.

This density-independent pixel size is equivalent to dpi a physical pixel on the screen. So px = dp * (dpi / 160) .

The Android system defines four pixel densities:

name abbreviation DPI
low ldpi Approx. 120dpi
medium mdpi Approx. 160dpi
high hdpi Approx. 240dpi
extra-high xhdpi Approx. 320dpi
extra-extra-high xxhdpi Approx. 480dpi
extra-extra-extra-high xxxdpi Approx. 640dpi
Dip

dpThe early naming, and dp exactly the same.

SP (for defining font size)

Scale independent pixels (scale-independent pixel). spand dp very similar but the difference is that theAndroid system allows users to customize text size (small, normal, large, oversized, and so on), when the text size is "normal" when the 1 sp =1 dp , and when the text size is "large" or "super-large" When, 1 sp >1 dp .

Therefore sp , it is mainly used to define the font size, and when the user sets the magnification font, only the text in the SP is magnified .

Pt

Standard length unit, 1 pt =1/72 inch = 0.035 cm.

Inch

inches, 1 inches = 2.54 cm (approx.)

Various scale units in Android development

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.