理解 android values/dimens

Understanding android values/dimens

所以我在 values/dimens & values/dimens-mdpi

<dimen name="rv_height">220dp</dimen>
<dimen name="rv_width">280dp</dimen>

以及 values-xxhdpi/dimens

中的以下内容
<dimen name="rv_height">260dp</dimen>
<dimen name="rv_width">320dp</dimen>

我的问题是,当我在 480 x 800 hdpi API 17 模拟器上 运行 这个时,为什么它从 xxhdpi 文件夹而不是常规的 dimendimens-mdpi 文件夹?

根据Official docs

To simplify the way that you design your user interfaces for multiple screens, Android divides the range of actual screen sizes and densities into:

ldpi (low) ~120dpi

mdpi (medium) ~160dpi

hdpi (high) ~240dpi

xhdpi (extra-high) ~320dpi

xxhdpi (extra-extra-high) ~480dpi

xxxhdpi (extra-extra-extra-high) ~640dpi

编辑:

我会尽力向您解释:

hdpi 上 480 像素的设备具有 320 dp,因为来自文档,"on a 240 dpi screen, 1 dp equals 1.5 physical pixels"。表示 400 px /1.5 = 320 dp.

现在,你有 values/dimens & values/dimens-mdpi && values-xxhdpi/dimens

再次根据文档

However, when the system is looking for a density-specific resource and does not find it in the density-specific directory, it won't always use the default resources. The system may instead use one of the other density-specific resources in order to provide better results when scaling. For example, when looking for a low-density resource and it is not available, the system prefers to scale-down the high-density version of the resource, because the system can easily scale a high-density resource down to low-density by a factor of 0.5, with fewer artifacts, compared to scaling a medium-density resource by a factor of 0.75.

结论:不保证在缺少 res 目录的情况下始终使用默认目录。在您的情况下,它已将高密度资源缩小到低密度。

我希望现在清楚了。