Android 当区域设置为 en_IN 时,可绘制对象是从 drawable-en-rCA 中选取的
Android drawable is picked from drawable-en-rCA when locale is en_IN
我在 drawable-en-rCA 文件夹中有一张图片。我没有像 drawable-en-rIN 或 drawable-in 这样的文件夹。当我将我的应用程序区域设置更改为 en_IN 时,可绘制对象是从 drawable-en-rCA 中提取的,而它应该是从默认的可绘制对象文件夹中提取的,因为不存在特定于 en_IN.[= 的可绘制对象12=]
有人可以帮我理解为什么会这样吗?
如果您在设备 运行 Android N 或更高版本上遇到此问题,我认为您的问题可能与此答案中提到的发现有关:. Google released a documentation on the Improvements to Resource-Resolution Strategy post Android N. There was also a bug report Incorrect resource resolution strategy above Android N, defaulting to en_GB and not default strings.xml 问题但事实证明这不是错误而是功能。这是他们的回复:
Starting in Android N, all English locales (except for US and US territories like Puerto Rico and American Samoa) fall back to some International English variant if such a locale is available.
So for en-CA, we would try these locales first, before falling back on en-GB (which is considered a representative of International English if there is no better International English locale): en-rCA (Canadian English), b+en+001 (International English), en (English). If you don't want en-GB strings to be picked up for en-CA, you should put resources in one of those three directories, as they would be considered a better match for en-CA.
对于您的情况,基于这些(特别是新的资源解析策略文档),似乎当您 select en_IN
时,如果 [=11= 中不存在任何资源],然后它会查找最近的国际英语目录,在您的例子中是 drawable-en-rCA
。如果它不在那里,只有它默认为默认的可绘制文件夹。
希望对您有所帮助。
我在 drawable-en-rCA 文件夹中有一张图片。我没有像 drawable-en-rIN 或 drawable-in 这样的文件夹。当我将我的应用程序区域设置更改为 en_IN 时,可绘制对象是从 drawable-en-rCA 中提取的,而它应该是从默认的可绘制对象文件夹中提取的,因为不存在特定于 en_IN.[= 的可绘制对象12=]
有人可以帮我理解为什么会这样吗?
如果您在设备 运行 Android N 或更高版本上遇到此问题,我认为您的问题可能与此答案中提到的发现有关:
Starting in Android N, all English locales (except for US and US territories like Puerto Rico and American Samoa) fall back to some International English variant if such a locale is available.
So for en-CA, we would try these locales first, before falling back on en-GB (which is considered a representative of International English if there is no better International English locale): en-rCA (Canadian English), b+en+001 (International English), en (English). If you don't want en-GB strings to be picked up for en-CA, you should put resources in one of those three directories, as they would be considered a better match for en-CA.
对于您的情况,基于这些(特别是新的资源解析策略文档),似乎当您 select en_IN
时,如果 [=11= 中不存在任何资源],然后它会查找最近的国际英语目录,在您的例子中是 drawable-en-rCA
。如果它不在那里,只有它默认为默认的可绘制文件夹。
希望对您有所帮助。