各位大神门我遇到一个问题,安卓图片文件简体和繁体区分如何创建目录
所以我创建了drawable-zh-rCN-hdpi ,drawable-zh-rCN-xhdpi ,drawable-zh-rCN-xxhdpi用于存放简体的图片, drawable-zh-hdpi等存放繁体的图片,但是实际发现简体没问题,但是切换语言繁体时候并不是在drawable-zh目录的图片,而是在我们默认drawable-hdpi目录,而我默认的drawable是放的英语的图片,请问大家怎么创建目录的,我现在三套图,简体繁体英语,大陆用简体,港澳台用繁体,其他的用英语
所以我创建了drawable-zh-rCN-hdpi ,drawable-zh-rCN-xhdpi ,drawable-zh-rCN-xxhdpi用于存放简体的图片, drawable-zh-hdpi等存放繁体的图片,但是实际发现简体没问题,但是切换语言繁体时候并不是在drawable-zh目录的图片,而是在我们默认drawable-hdpi目录,而我默认的drawable是放的英语的图片,请问大家怎么创建目录的,我现在三套图,简体繁体英语,大陆用简体,港澳台用繁体,其他的用英语
截图方便打假查看我的drawable目录
zh无效,不要用。繁体一般是zh-rTW,可以看看代码的Locale.TRADITIONAL_CHINESE
中文(中国):zh-rCN
中文(台湾):zh-rTW
中文(香港):zh-rHK
谢谢你的回复,但是你说zh无效我用三星s7试了,设置澳门繁体 时候读取是默认目录,设置澳门简体的读取的是zh目录的,真的奇怪,感觉安卓一点不规范化
简体包括中国,香港,澳门和新加坡
繁体包括香港,澳门和台湾
默认zh应该是简体,这个不太了解。
参考https://stackoverflow.com/questions/4189875/simplified-and-traditional-chinese-vs-regions?rq=1
我从你的参考https://developer.android.com/guide/topics/resources/providing-resources#AliasResources 文档里面找到了解决方案,大概就是 建立drawable-zh-rTW ,drawable-zh-rHK,drawable-zh-rMO 各自的目录,目录里面写xml文件引用她们各自对应语言的图片文件就行,因为我港澳台是一样的图,所以把xml复制三份就可以,这样的apk并不会增加太多,
For example, imagine you have an app icon, icon.png, and need unique version of it for different locales. However, two locales, English-Canadian and French-Canadian, need to use the same version. You might assume that you need to copy the same image into the resource directory for both English-Canadian and French-Canadian, but it's not true. Instead, you can save the image that's used for both as icon_ca.png (any name other than icon.png) and put it in the default res/drawable/ directory. Then create an icon.xml file in res/drawable-en-rCA/ and res/drawable-fr-rCA/ that refers to the icon_ca.png resource using the <bitmap> element. This allows you to store just one version of the PNG file and two small XML files that point to it. (An example XML file is shown below.)例如,假设您有一个app图标,icon.png,并且需要针对不同区域设置的唯一版本。但是,两个语言环境,英语 - 加拿大语和法语 - 加拿大语,需要使用相同的版本。您可能认为需要将相同的图像复制到英语 - 加拿大语和法语 - 加拿大语的资源目录中,但事实并非如此。相反,您可以将用于两者的图像保存为icon_ca.png(除icon.png以外的任何名称)并将其放在默认的res / drawable /目录中。然后在res / drawable-en-rCA /和res / drawable-fr-rCA /中创建一个icon.xml文件,该文件使用<bitmap>元素引用icon_ca.png资源。这允许您只存储一个版本的PNG文件和两个指向它的小型XML文件。 (示例XML文件如下所示。)