سؤال

I've read the docs about Android Resources and I think I've understood the best-matching logic used by android to identify in which directory a particular resource should be searched first.. Supposing that drawable-hdpi, drawable-en-port and drawable-en* match the current device configuration, drawable-en-port is the best matching directory.. My question is, if a drawable is not found in drawable-en-port, does the system look directly in drawable or does it look in the second-best-match drawable-en and then in the third best match drawable-hdpi and so on until it reaches drawable? I suppose it works this way, but I did not find it explicitly said in the docs (unless I've read them too quickly and you will surely kill me :) ).

هل كانت مفيدة؟

المحلول

Yes it looks first in the drawable-en, then drawable-hdpi because language qualifier has higher precedence. If value was still not found drawable directory is searched. It is in accordance with: How Android Finds the Best-matching Resource

If drawable-en contains matching resource then drawable-hdpi and drawable would be eliminated based on step 4 of the algorithm.

نصائح أخرى

I read the intro portion

assume the following drawable directories each contain different versions of the same images

In your example Android would ignore the drawable-en-port folder because it does not have that drawable name in it. It would only look in the folders that have that drawable, therefore selecting the best matching folder. It would only select 'drawable' if there were no folders with a matching configuration and image.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top