Android Size Metrics

Source: Internet
Author: User

PPI: pixel density, pixels per inch (1inch=2.54cm), which is the number of pixels per screen. Pixel density =√{(length pixels ^2+ width pixels ^2)}/screen size.

Dpi:dots per inch, point in dots, refers to the printing accuracy in the printing industry. In the official Android development Guide, the meaning of the PPI is the same as that of pixels per inch.

Resolution: Refers to the number of pixels in the horizontal and vertical direction of the phone screen. For example, the FHD resolution, or full-high definition, is also called a 1080P resolution or a resolution of 1080*1920.

Contact the above three concepts, the physical size 5.0 inch resolution is 1920x1080 's screen pixel density is 441PPI, belongs to the xxhdpi range.

PX: physical pixels, which appear smaller on a screen with high resolution (that is, a large dpi).

Dp:device independent pixels, early also writing dip, density-independent pixels. displayed on different DPI screens with different px.

Sp:scale-independent pixels, which is a DP, is affected by the user's font preferences and is generally used as a font size

The DP and SP are abstract pixels, and Android automatically converts the values of the SP and DP to pixel units at run time.

Official conversion formula: pixels = DPS * (ppi/160), the coefficient is ppi/160, for example, for the above 1080p screen, px=dp*441/160, draw a 320dp horizontal line, will occupy the screen of 882/1080

On the 160dpi screen (that is, HVGA, since the general pixels are squares, the resolution is the same in the general direction), the conversion factor of DP to PX (pixel density) is 1, at this time 1px=1dp=1sp.

Note 1: The size of the text is used in SP units, the dimensions of the view are used DP units.

Note 2: When drawing a thin divider line on the screen (with DP and SP Blur): <view layout_width= "match_parent" layout_height= "1px"/>

Note 3:android:layout_weight Set the view relative width: <android:layout_width= "0DP" android:layout_weight= "1"/>

Note 4:margin is the margin, which is the interval between views, and padding is the padding, which refers to the distance of the content area on the view from its boundary

Resources:

[1] Http://stackoverflow.com/questions/2025282/difference-between-px-dp-dip-and-sp-in-android

[2] Android programming:the Big Nerd Ranch guide§8.4.2 Page133

[3] Https://en.wikipedia.org/wiki/Dots_per_inch

[4] http://blog.csdn.net/zhaokaiqiang1992

[5] Http://developer.android.com/guide/topics/resources/more-resources.html#Dimension

Android Size Metrics

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.