[Description of the PX dpi dip density densitydpi in turn]android

Source: Internet
Author: User

Conceptual interpretation

Noun

Explain

Px

(Pixel pixels)

Different devices show the same effect. The "Same" here means that the number of pixels does not change, such as specifying a UI length of 100px, regardless of the resolution of the UI length is 100px. This is why the UI is magnified and distorted on small-resolution devices, and is scaled down at large resolutions.

Screen Size

(Screen size)

Generally speaking, the size of a mobile phone screen, such as 1.6-inch, 1.9-inch, 2.2-inch, refers to the length of the diagonal, not the phone area. We can get the width and length of the phone according to the Pythagorean theorem, and of course the area.

Resolution

Resolution

Refers to the number of pixels in the vertical and horizontal direction of the phone's screen. For example, the resolution is 480*320, which means that the device has a vertical orientation of 480 pixels and a horizontal 320 pixel point.

dpi

(dots per inch

  pixel density)

refers to the number of pixels per inch. such as 160dpi refers to the mobile phone horizontal or vertical direction of 160 pixels per inch distance. Assuming the device resolution is 320*240, the screen length is 2 inches wide and 1.5 inches, dpi=320/2=240/1.5=160

Note: This value corresponds to displaymetrics The value of the property densitydpi in the class. For details, refer to http://www.cnblogs.com/wader2011/archive/2011/11/28/2266669.html

Density

Density

Refers to the number of pixels per square inch.

Density=resolution/screen size

Note: in Displaymetrics properties in class density the value is dpi/160 , can be used to px with the Dip conversion of each other. Please refer to http://www.cnblogs.com/wader2011/archive/2011/11/28/2266684.html for details.

Dip

(device-independent pixel, device independent pixels)

With DP, can be used as a unit of length, different devices have different display effect , this and equipment hardware, generally we in order to support WVGA, HVGA and QVGA recommend this, do not rely on pixels. The corresponding formula for dip and specific pixel values is dip value = device density /160* pixel value , Can be seen on devices with a dpi (pixel density) of 160dpi 1px=1dip

Sp

(Scaledpixels

Enlarge pixels)

Mainly used for font display (best for TEXTSIZE). According to Google's suggestion, TextView's font size is best to use SP to do units, and view the source of TextView know that Android by default using the SP as the font size units.

Summarize

We can use the following ideas to explain why the dip instead of PX units:

    1. The device will end up with PX as the unit of length.
    2. If we use PX directly as a unit it will cause the UI to appear inappropriate scaling on different resolution devices. So we need a new unit that will eventually be able to convert the appropriate coefficients into PX to make the UI appear the right size.
    3. Does the dip meet this requirement?

The corresponding formula for dip and specific pixel values dip value = device density /160* pixel value can be known

Pixel value =dip value/(device density /160) , where the dip value is the length size we specify, then the pixel value, 160 is also colonization, that is, the final UI pixel value is only affected by the pixel density dip, the dip is equivalent to the conversion factor, the coefficient of the value of the number of devices to decide. The dip therefore meets this requirement.

About SP can also understand this

[Instructions for px dpi dip density densitydpi in]android

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.