px,dp,sp for android

Android unit: px , dp , sp

px: pixels .

dp:Units independent of pixels, dp = dip(Device Independent pixels) The conversion formula is px = dp * (dpi/160) , on a screen with dpi of 160 (160 pixels per inch): 1dp = 1px.

dpi: the number of pixels per inch length (the size of the phone refers to the diagonal length of the phone screen), dpi(dots per inch) = sqrt(px_x * px_x + px_y * px_y) / size; size is the diagonal length, The unit is inches.

       dpi indicates the fineness of the screen, the same size screen, the higher the dpi, the higher the fineness, the same size, the higher the pixel.

sp:scaled pixels The pixels that can be scaled, usually used to specify the size of the font (scalable). 

     In the Android phone setting options, after the font size is modified, the unit set to sp will follow the change, so the general font settings use sp.



Guess you like

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