About dp, px and sp

About dp, px and sp

dip :device independent pixels. Different devices have different display effects. This is related to the device hardware. In order to support WVGA, HVGA and QVGA, it is recommended to use dip instead of pixels

px :pixels (pixels) ). Different devices have the same display effect, HVGA represents 320X480 pixels, which is used more.

sp :scaled pixels (scale-independent pixels). Mainly used for font display.

User interfaces are often designed in pixels. The problem with this is that if you run on a higher resolution display with dots per inch (dip) program, the user interface will appear small, and in some cases, the user interface may be so small that it is difficult to read the content.

dp (density-independent pixel): An abstract unit based on screen density.
On a 160 dots per inch (standard resolution) monitor, 1dp=1px.
On a 240 dots per inch (high resolution) monitor, 1dp=1.5px.
On a 120 dots per inch (low resolution) monitor ,1dp=0.75px

dip: same as dp

sp (scale-independent pixels): similar to dp, but can be scaled according to the user's font size preference.

In order for the user interface to display properly on current and future display types, it is recommended to always use sp as the unit for text size and dip as the unit for figure size.



Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326836272&siteId=291194637