77

根据http://developer.android.com/training/multiscreen/screendensities.html

提到了以下比例因子

xhdpi:2.0 hdpi:1.5 mdpi:1.0(基线)ldpi:0.75

我想知道 xxhdpi 的比例因子是多少?

4

2 回答 2

282

android.util.DisplayMetrics中,您可以看到缩放因子为0.00625

/**
 * Scaling factor to convert a density in DPI units to the density scale.
 * @hide
 */
public static final float DENSITY_DEFAULT_SCALE = 1.0f / DENSITY_DEFAULT;

其中DENSITY_DEFAULT为 160 --> 比例因子 = 1.0f / 160 = 0.00625。

sizeScale = DENSITY_DEFAULT_SCALE * DENSITY_DPI

由此:

  • ldpi = 0.00625 * 120 -> 0.75
  • mdpi = 0.00625 * 160 -> 1.0
  • hdpi = 0.00625 * 240 -> 1.5
  • xhdpi = 0.00625 * 320 -> 2.0
  • xxhdpi = 0.00625 * 480 -> 3.0
  • xxxhdpi = 0.00625 * 640 -> 4.0

不完全是火箭科学,但希望这对某人有用:)

于 2013-09-06T11:04:19.910 回答
6

如果您查看Metrics and Grids,您会发现 xxhdpi 是 480 dpi,是基线 (mdpi @ 1.0) 的 3 倍。换句话说,xxhdpi 的比例因子是 3.0

于 2013-09-06T10:43:21.967 回答