Does Android override resources files in ascending or descending order?

后端 未结 1 1599
梦毁少年i
梦毁少年i 2021-01-19 05:18

Android has various folders it goes through to set up its resources. For example, values-small, values-normal, values-large, drawable-mdpi, drawable-hdpi, drawable-xhd

1条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-19 06:06

    Here's a great overview from the 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).

    So to answer your question:

    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?

    It will look at the current dpi and attempt to retrieve the resource from that directory. If not available, it will only search the lower densities in a descending order. It will not search the higher densities.

    0 讨论(0)
提交回复
热议问题