Android 将物理屏幕测量值转换为密度一(不是运行时!)

Android convert physical screen measurements to density one (not runtime!)

因此,据我所知,我们可以使用下一个公式:
density = SQRT(width*width+height*height)/screen_size.

例如,Nexus 6 (6.0", 1_440*2_560) 应提供 490 dpi(大约),但 Android Studio 预览屏幕显示此设备 560 dpi.

我错过了什么?

关于 Nexus 6,制造商密度为 560,但物理密度约为 493。在考虑比例因子之前,请务必考虑制造商密度。

尽管每个设备都有自己的屏幕密度,Android 将设备纳入最接近的密度 "bucket":

  • 420 dpi
  • 560 dpi
  • xhdpi
  • xxhdpi

如 Android Studio 中所见:

尽管 Nexus 6 和 6P 的物理屏幕密度不同,但两种设备将使用相同的可绘制资源。