Article Directory
First, the concept
- px: pixels (pixels)
- dp / dip: device independent pixels (device independent pixel)
- sp: scaled pixels (pixels amplification)
- ppi: pixels per inch (pixel density, is represented by the number of pixels per inch owned)
- dpi: dots per inch (dots per inch)
Generally, we can find on a mobile phone network to a certain configuration information can be obtained by resolution (px), size (inch) and ppi.
1.px (pixels)
A pixel is generally regarded as a complete image of the sample minimal. Commonly referred to a resolution such as 1280 * 720, it refers to display 1280 * 720 pixels.
2.dp (device independent pixel)
The hardware and related equipment, different devices have different display. In doing the project, in order to fit a wide range of mobile phones on the market resolution recommended dp.
3.sp (enlarged pixel)
SP name is Scale-independent Pixels, a font size , which is consistent with the concept and DP, but also in order to maintain device-independent.
4 inch (Inch)
5.5 inches phone does not refer to the length and width, but rather oblique diagonal 5.5 inches.
5.ppi (image sampling rate)
Pixels Per Inch, pixels (pixel) per inch diagonal have the number.
Ppi calculated as:
Calculated with a long number of pixels with a high number of pixels in the diagonal direction (right triangle), and then divided by the number of pixels in the diagonal screen size is a ppi.
Examples of PPI: 4.3 inches with a resolution of 1280 * 720
note:
ppi only a single value is determined by the resolution and size.
ppi as the effect of the image displayed on the same. The small things ppi display device placed on a large ppi equipment, things will be significantly smaller.
6.dpi (print resolution)
Dots Per Inch, dpi = number of pixels per inch in an image .
Screen density is closely related to the dpi, the greater the density, the more content per inch satisfied points.
Now, he said dpi = ppi, the calculation is also consistent.
Difference is, ppi display commonly used in mobile phone terms, dpi terms commonly used in the printed output.
Second, the conversion
1.px and dp
2.dpi=ppi
Example: Configuring simulator
target model for the resolution of 1920 * 1080, ppi is 401, the size is 5.5 inches.
We use dp and sp as a resource unit.
(1) you can specify any simulator dpi
So the resolution only need to simulator is also set to 1920 * 1080, the size is 5.5 inches, dpi = 320.
(2) simulator dpi is a fixed value
And because they can not set the same target model dpi, then we can only adjust the screen resolution size to achieve the same effect on different dpi models.
For example: the simulator is only 320dpi dpi
Provided the original length of the screen a px, width b px, and the new screen resolution ka kb.
The new screen length:
but not to.
Why is the coefficient
Reference:
the Android in px, ppi, dpi, dp, dip, sp analytical concept