PPI = Pixels per inch, number of pixels on average, "pixel density"
- xhdpi:2.0
- hdpi:1.5
- mdpi:1.0 (Baseline)
- ldpi:0.75
DRAWABLE-LDPI, drawable-mdpi, drawable-hdpi accuracy are low, medium (Android default), high.
The corresponding image sizes are: 36x36, 48x48, 72x72.
xxhdpi:144*144
xhdpi:96*96
hdpi:72*72
mdpi:48*48
Ldpi:36*36
DP is a virtual pixel that is automatically adapted to devices with different pixel densities, such as:
At 320x480 resolution, pixel density is 160,1dp=1px
At 480x800 resolution, pixel density is 240,1dp=1.5px
Calculation formula: 1dp* pixel density/160 = actual number of pixels
The difference between drawable-hdpi, drawable-mdpi and drawable-ldpi:
(1) drawable-hdpi contains high-resolution images, such as WVGA (480x800), FWVGA (480x854)
(2) drawable-mdpi contains medium-resolution images, such as HVGA (320x480)
(3) drawable-ldpi contains low-resolution images, such as QVGA (240x320)
The system will be based on the resolution of the machine to each of these folders to find the corresponding picture.
the PPI is calculated as:
PPI =√ (length pixels 2 + width pixel number 2)/Screen diagonal inches
Dp:density-independent pixels, with 160PPI screen as standard, then 1dp=1px,
Conversion formulas for DP and PX:
dp*ppi/160 = px. such as 1DP x 320ppi/160 = 2px.
Sp:scale-independent pixels, which is the font unit for Android, is the standard 160PPI screen, when the font size is 100%, 1sp=1px.
conversion formula for SP and px : sp*ppi/160 = px
It concludes that:
PX = dp*ppi/160
dp = px/(ppi/160)
PX = sp*ppi/160
sp = px/(ppi/160)
DP = SP?
Source: http://www.cnblogs.com/bluestorm/p/3640786.html
From for notes (Wiz)
Android development: PX and DP, SP conversion formula? (ZZ)