In the Android system, the Unit DP is dip: Device Independent pixels (device independent pixel ).
Dip
: Device Independent pixels (device independent pixels). Different devices have different display effects. This is related to the hardware of the device. We recommend that you use this feature to support WVGA, hvga, and qvga, instead of pixels.
Px
: Pixels (pixels). Different devices have the same display effect. Generally, we use hvga to represent 320x480 pixels, which is usually used.
PT
: Point is a standard length unit, 1pt = 1/72 inch, used in the printing industry, very easy to use;
SP
: Scaled pixels (zoom in pixels). It is mainly used to display the best for textsize in fonts.
DP is dip. This is basically similar to sp. You can use DP or SP to specify attributes such as length and height.
If you set the font, you need to use sp. DP is not related to density. SP is not only related to density, but also to scale. If the screen density is 160, DP and SP are the same as PX.
1dp = 1sp = 1px, but if PX is used as the unit, if the screen size remains unchanged (assuming it is still 3.2), the screen density is changed to 320. Set the original textview width
320 PX, 3.2 inch screens with a density of 160 are half shorter than 3.2 inch screens with a density. But if it is set to 160dp or 160sp. The system automatically
The width property value is set to 320px. That is, 160*320/160. Of these, 320/
160 can be called the density ratio factor. That is to say, if DP and SP are used, the system will automatically convert according to the screen density change.