Issue
when you make an android app you can store every string in the app in one file, and you can make multiple files, each file will be for specific language or country, and the app will select the right file automatically. You can do the same thing with drawables for multiple densities. but what happen when the app don't find the one it needs, for example if there are 4 drawable folders:
drawable-mdpi
drawable-hdpi
drawable-xhdpi
drawable-xxhdpi
and each one of theme contains the same picture but with different size, and the developer used this picture. What will happen if the developer tried his app in a device with low density, or a device with extra-extra-extra density, I mean what will happen if you launched an app in a device that have characteristics that don't match any of a specific resource qualifiers?
Solution
For the narrow case of drawables varying by density, Android will choose the closest density and scale the image.
More generally, this is why for things other than drawables/mipmaps, you always have a master set of resources in the base resource directories (e.g., res/layout/, res/menu/, res/values/), and override them as needed in directories with resource set qualifiers (e.g., res/layout-sw640dp/).
Because, more generally, if you do wind up in a situation where you request a resource and there is no possible match, you get a ResourceNotFoundException.
For example, suppose that you want to support two languages in your app: English and Spanish (and you are willing to ignore regional differences for the moment, such as UK English versus US English). You then have two sets of string resources: English and Spanish. If you put one set in res/values/ and the other in a language-specific directory (e.g., res/values-es/ for Spanish), and the app winds up on a device whose locale is set to something else (e.g., French), the user gets whatever you put in res/values/. If, on the other hand, you decide to put both languages in language-specific directories (e.g., res/values-es/ and res/values-en/), the French user's app crashes with a ResourceNotFoundException when the app tries to load a string resource and cannot find one that works for the device as configured.
Answered By - CommonsWare
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.