PX Dip dp dpi Density SP one time understand

Source: Internet
Author: User

1 px pixels per pixel and device for devices such as 480 * 320 resolution of the phone, the landscape is 480 pixels in length and 320 pixels vertically. More pixels at fixed length, higher pixels, smaller pixels, sharper images.

2. DPI:d ots per inch pixel number, common value 120,160,240,320. Corresponding to the Low,medium,high,xhigh, DPI value, and device-related (the same size of the phone resolution has a high bottom), such as the 320* 240 mobile phone, the size of 2.0 * 1.5 (inch), DPI is 160. Usually the size of the mobile phone, such as the new 5-inch large-screen mobile phone as long as 599 what you are waiting for. Wait a minute. The size here refers to the diagonal size of the phone screen. The Pythagorean theorem can be changed to a long and wide size. The general scale rule is 4:3 or 16:9.

3. dip:density independent pixels, device independent pixels.

Official Introduction:

Density-independent Pixel (DP)  
A Virtual pixel unit that you should use when defining UI layout, to express Layout dimensions or position in a density-independent way. 
The density-independent pixel are equivalent to one ph Ysical pixel on a (DPI screen), which is the baseline density assumed by the system for a "medium" density screens. At runtime, the system transparently handles any scaling of the DP units, as necessary, based on the actual density of the Screen on use. The conversion of DP units to screens pixels is SIMPLE:PX = DP * (dpi/160). For example, on a-DPI screen, 1 DP equals 1.5 physical pixels. Should always use DP units when defining your application ' s UI, to ensure proper display of your UI on screens with Di Fferent densities.

The relationship between pixel dip and pixel in the abstract sense: 1dip = (current phone dpi/160) px, such as the above DPI is 240 of the phone, 1dip equivalent to 1.5px, that is, different phone 1dip equals to a different number of PX.    For a phone with a dpi of 320, the 1dip is equivalent to 2px. By defining an abstract unit such as a dip, the developer uses the dip as a unit to develop controls that are the same size on different phones. If you use PX as a unit, you can imagine that on a screen with a low dpi, which is a relatively sparse pixel point, the control will be larger than the DPI-high screen. (because you need to take up the same number of PX, set the button to 10px).

4. DP is dip

5. Density: The current phone dpi and standard dpi (px/inch) ratio, such as 480 * 320 resolution of the phone size is 2.0*1.5.     The DPI is 240. desity = 240/160 = 1.5

GetContext (). Getresources (). Getdisplaymetrics (). Density obtained is density, which is the value above 1.5

Mdensity = GetContext (). Getresources (). Getdisplaymetrics (). densitydpi Gets the DPI value. Which is the 240 above

GetContext (). Getresources (). Getdisplaymetrics (). Density document This is a very important sentence.

This value does isn't exactly follow the real screen size ( xdpi ydpi as given by and, but rather was used to scale the size Of the overall UI in steps based on gross changes in the display DPI. For example, a 240x320 screens would have a density of 1 even if their width is 1.8 ", 1.3", etc. However, if the screen resolution are increased to 320x480 but the screens size remained 1.5 "x2" then the density would be I Ncreased (probably to 1.5).

Reference: http://www.cnblogs.com/yaozhongxiao/archive/2014/07/14/3842908.html

PX Dip dp dpi Density SP one time understand

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.