一英寸中像素的个数称为“像素密度”。
As a result, UI elements (such as a button) appear physically larger on low-density screens and smaller on high-density screens. (高密度屏幕中的控件要比低密度屏幕中的控件小。)
screen density = screen width (or height) in pixels / screen width (or height) in inches
附一: Pixel density 计算器: http://kingscalculator.com/en/other-calculators/pixel-density-calculator
附二:常用屏幕的PPI
Mobile phones
Tablets
Computer displays
https://material.io/devices/
Density-independent pixels (dp)
"Density independence" refers to the uniform display of UI elements on screens with different densities.
dp -- 密度无关像素, 能适应不同的屏幕大小,Android界面设计中尽量使用dp作为单位。
dp = (width in pixels * 160) / screen density
例子:32 x 32 px icon with a screen density of 320 equals 16 x 16 dp
Scaleable pixels (sp) (用于字体大小设定)
When developing for Android, scaleable pixels (sp) serve the same function as dp, but for fonts. The default value of an sp is the same as the default value for dp.
Image scaling
Images can be scaled to look the same across different screen resolutions by using these ratios:
Screen resolution | dpi | Pixel ratio | Image size (pixels) |
xxxhdpi | 640 | 4.0 | 400 x 400 |
xxhdpi | 480 | 3.0 | 300 x 300 |
xhdpi | 320 | 2.0 | 200 x 200 |
hdpi | 240 | 1.5 | 150 x 150 |
mdpi | 160 | 1.0 | 100 x 100 |