Android是否按升序或降序覆盖资源文件?

Android有各种文件夹来设置其资源.例如,值 – 小,值 – 正常,值 – 大,drawable-mdpi,drawable-hdpi,drawable-xhdpi等.Android如何从这些文件夹中拉出来?它是从较小的(值 – 小的还是可绘制的 – mdpi)开始并向上运行到较大的值(值大和可绘制的xhdpi),还是从较大的开始反向工作,然后用较小的? 最佳答案 以下是
official Android docs的精彩概述:

When selecting resources based on the screen size qualifiers, the
system will use resources designed for a screen smaller than the
current screen if there are no resources that better match (for
example, a large-size screen will use normal-size screen resources if
necessary). However, if the only available resources are larger than
the current screen, the system will not use them and your application
will crash if no other resources match the device configuration (for
example, if all layout resources are tagged with the xlarge qualifier,
but the device is a normal-size screen).

所以回答你的问题:

Does it start with the smaller (values-small or drawable-mdpi) and
work its way up to the larger (values-large and drawable-xhdpi) or
does it work in reverse starting with the larger and then overriding
with the smaller?

它将查看当前的dpi并尝试从该目录中检索资源.如果不可用,它将仅按降序搜索较低密度.它不会搜索更高的密度.

点赞