Android Length Unit DP Dip SP PX PT

Source: Internet
Author: User

Basic knowledge

QVGA 240*320 pixels |

VGA 640*480 pixels |

WVGA 800*480 pixels |

HVGA 480*320 pixels |

See that a lot of people don't understand the difference between DP, SP, and PX: Now let's introduce the DP and SP.

DP is also dip. This is basically similar to SP.

You can use a DP or SP if you set properties that represent length, height, and so on. However, if you set the font, you need to use the SP. The DP is not density-independent, and the SP is not related to scale, except for density. If the screen density is 160, then the DP and SP and PX are the same.

1DP=1SP=1PX, but if you use PX as the unit, if the screen size is constant (assuming 3.2 inches), the screen density becomes 320. So the original width of the TextView is set to 160px, in the density of 320 of the 3.2-inch screen is more than the density of 160 of the 3.2-inch screen to see the half-short.

But if it is set to 160DP or 160SP. The Width property value is automatically set to 320px. That's 160*320/160. 320/160 of these are called density scale factors. That is, if you use the DP and SP, the system will automatically convert based on the change in screen density.

  Look at the meaning of other units px: represents the actual pixel of the screen. For example, the 320*480 screen has 320 pixels in the landscape and 480 pixels in the portrait. In: represents inches, which is the physical size of the screen. Equal to 2.54 centimeters per inch. For example, describe the size of a mobile phone screen, often said, 3.2 (English), 3.5 (English), 4 (English) inch refers to this unit. These dimensions are the diagonal length of the screen. If the phone's screen is 3.2 inches, the diagonal length of the phone's screen (viewable area) is 3.2*2.54=8.128 cm. Readers can measure their own phone screen to see if the actual size is the same. MM: Represents the millimeter, which is the physical size of the screen. PT: Represents a point, which is the physical size of the screen. 1/72

with a size of 1 inches

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.