根据在 Android 上选择的语言更改颜色
Change colors according to the selected language on Android
如何在 Android Studio 中将(语言)colors.xml
文件上下文化?
这是我目前的代码:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">#999900</color>
</resources>
colorPrimary
对所有语言保持不变。
当设备的语言是法语时,如何让 colorPrimary
变成黑色 (#000000
)?
您可以将 colors.xml
文件复制到不同的资源文件夹中。每种语言一个。
res/values/colors.xml --> Default colors
res/values/values-en --> Colors for English
res/values/values-es --> Colors for Spanish
然后,您可以覆盖每个文件夹上的 <color name="colorPrimary">#999900</color>
。
您不需要为所有可能的语言创建文件夹...如果找不到特定语言的 color.xml
,将使用默认文件。
如何在 Android Studio 中将(语言)colors.xml
文件上下文化?
这是我目前的代码:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">#999900</color>
</resources>
colorPrimary
对所有语言保持不变。
当设备的语言是法语时,如何让 colorPrimary
变成黑色 (#000000
)?
您可以将 colors.xml
文件复制到不同的资源文件夹中。每种语言一个。
res/values/colors.xml --> Default colors
res/values/values-en --> Colors for English
res/values/values-es --> Colors for Spanish
然后,您可以覆盖每个文件夹上的 <color name="colorPrimary">#999900</color>
。
您不需要为所有可能的语言创建文件夹...如果找不到特定语言的 color.xml
,将使用默认文件。