In my app in the res
folder, there are values folders for different devices. For example:
values-mdpi
Values-hdpi
values-v14
values-v17
values-w480
values-w720
etc.
I wonder what is the priority of these folders for Android?
Let's imagine couple devices:
first : 480*800 hdpi v14
second: 320*480 mdpi v17
third : 720*1280 hdpi v17
What folder would Android use for each of them?
android:priority. The priority that should be given to the parent component with regard to handling intents of the type described by the filter.
And the highest priority possible would be the maximum integer that android allows, which is (2^31 - 1).
The res/values folder is used to store the values for the resources that are used in many Android projects to include features of color, styles, dimensions etc.
You can find the priority of resource folders here in this page. Basically it is used to support different devices and configurations.
Android uses a certain logic to determine the best possible matching resource folder for a device. This is explained in this documentation page.
Regarding your devices query:
In the list provided by you, values-w480 (devices with lowest width of 480dp, only from API 13)
has got the highest merit. So whichever device meets that criteria, it'll take resources from that folder.
The values-vXX (devices with API >= XX)
has got the lowest merit. So if the other folders are not taken, then only Android takes resources from this folder. Check the table listing the resources qualifiers for more info on that topic. The resource qualifiers are listed in the table in the order of precedence of resource qualifiers.
This is what the Android documentation states:
Be aware that, when the Android system picks which resources to use at runtime, it uses certain logic to determing the "best matching" resources. That is, the qualifiers you use don't have to exactly match the current screen configuration in all cases in order for the system to use them. Specifically, when selecting resources based on the 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). For more information about how the system selects resources, read How Android Finds the Best-matching Resource.
Source
How Android Finds the Best-Matching Resource
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With