Dpi, ppi, dip, dp, px, sp, dpippi
Basic Concepts
1. dpi (dots per inch): The number of dots per inch; ppi (Pixel per inch): The number of dots per inch. Designed for the monitor, dpi = ppi.
2. dip (device independent pixels) devices are independent pixels. Different devices have different display effects, which are related to device hardware and do not depend on pixels.
3. dp (Density-independent pixel), an abstract unit based on screen Density. 1dp = 1px on a display at 160 o'clock per inch.
4. px (pixels) pixels are the actual pixel units on the screen.
5. sp (Scale-independent pixels), which is the font unit of Android, based on the 160PPI screen. When the font size is 100%, 1sp = 1px.
Second calculation method and conversion
Dpi = √ (Length: + width:)/screen diagonal inches
Conversion Formula of dp and px:
Dp * ppi/160 = px. For example, 1dp x 320ppi/160 = 2px.
Sp and px conversion formula:
Sp * ppi/160 = px