Issue
How do I contextualize (language) colors.xml
file in Android Studio?
This is my code currently:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">#999900</color>
</resources>
colorPrimary
remains the same for all languages.
How do I make colorPrimary
be black (#000000
) when the device's language is French?
Solution
You can copy the colors.xml
file into different resource folders.. one for each language.
res/values/colors.xml --> Default colors
res/values/values-en --> Colors for English
res/values/values-es --> Colors for Spanish
Then, you can override the <color name="colorPrimary">#999900</color>
on each folder.
You don't need create a folder to all possible languages... If color.xml
isn't found for a specific language, the default file will be used.
Answered By - W0rmH0le
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.