当前位置: 动力学知识库 > 问答 > 编程问答 >

android - Use resource localization as a means to change colors

问题描述:

Resource Localization is a tool for android developers that helps them support multiple users with different locales. For instance, if I want to display different names for French and Italian users I must include the following lines in their respective directories.

In res/values-fr/strings.xml

<string name="my_app_name">Mon programme</string>

and in res/values-it/strings.xml

<string name="my_app_name">Il mio programma</string>

The application decides which string to show, based on the device locale. It can also be chosen by the programmer explicitly.

There are always a number of languages that we don't want to use. Is is possible to appoint each of these languages to a color (for instance one for teal and one for orchid) and allow the user to select their desired color theme in the program?

In res/values-xx/strings.xml where xx is a language I don't want to use, I will have

<color name="my_background">#008080</color> <!-- Teal -->

and in res/values-yy/strings.xml I will have

<color name="my_background">#DA70D6</color> <!-- Orchid -->

In the application I can alternate between these two by user's choice. Can I use this scheme to implement having different color themes in the application? If not, what's a good solution?

分享给朋友:
您可能感兴趣的文章:
随机阅读: