The relationship between px, pt, ppi, dpi, dp, sp

http://www.woshipm.com/pmd/176328.html

QQ20150717160352

respective definitions:

  • px: pixel, pixel, the most basic unit of a picture or photo on an electronic screen
  • pt: point, point, a common unit in the printing industry, equal to 1/72 of an inch
  • ppi: pixel per inch, the number of pixels per inch, the higher the value, the finer the screen
  • dpi: dot per inch, how many dots per inch, the higher the value, the finer the picture
  • dp: dip, Density-independent pixel, is the length unit for Android development, 1dp means 1px length when the screen pixel density is 160ppi
  • sp: scale-independent pixel, the font size unit for Android development.

 

Conversion formula:

1pt= (DPI / 72) px

 

dpi=ppi

 

ppi= the number of pixels on the diagonal of the screen / the length of the diagonal line = √ (the horizontal pixels of the screen^2 + the vertical pixels of the screen^2) / the length of the diagonal

 

1dp=(screen ppi/160)px

 

When the text size is "Normal", 1sp=1dp, and when the text size is "Large" or "Extra Large", 1sp>1dp.

In general, it can be considered that sp=dp.

 

Replenish:

dp is the unit of length in Android development, and it has a different correspondence with px according to different screen resolutions.

Android screens vary in size, and are divided into the following specifications according to their pixel density:

QQ20150717160404

1dp is defined as 1px at a screen density value of 160ppi, i.e., at mdpi, 1dp = 1px. Taking mdpi as the standard, the density value ratio of these screens is: ldpi : mdpi : hdpi : xhdpi : xxhdpi = 0.75 : 1 : 1.5 : 2 : 3; that is, under the density of xhdpi, 1dp=2px; in the case of hdpi, 1dp=1.5px. Other analogies.

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324890605&siteId=291194637