Size unit in Android

Source: Internet
Author: User

In the Android system, the Unit DP is dip: Device Independent pixels (device independent pixel ).

 

Dip
: Device Independent pixels (device independent pixels). Different devices have different display effects. This is related to the hardware of the device. We recommend that you use this feature to support WVGA, hvga, and qvga, instead of pixels.


Px
: Pixels (pixels). Different devices have the same display effect. Generally, we use hvga to represent 320x480 pixels, which is usually used.


PT
: Point is a standard length unit, 1pt = 1/72 inch, used in the printing industry, very easy to use;


SP
: Scaled pixels (zoom in pixels). It is mainly used to display the best for textsize in fonts.


DP is dip. This is basically similar to sp. You can use DP or SP to specify attributes such as length and height.
If you set the font, you need to use sp. DP is not related to density. SP is not only related to density, but also to scale. If the screen density is 160, DP and SP are the same as PX.
1dp = 1sp = 1px, but if PX is used as the unit, if the screen size remains unchanged (assuming it is still 3.2), the screen density is changed to 320. Set the original textview width
320 PX, 3.2 inch screens with a density of 160 are half shorter than 3.2 inch screens with a density. But if it is set to 160dp or 160sp. The system automatically
The width property value is set to 320px. That is, 160*320/160. Of these, 320/
160 can be called the density ratio factor. That is to say, if DP and SP are used, the system will automatically convert according to the screen density change.

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.