是否有可能从XML文件动态地改变资源? [英] Is it possible to dynamically change resources from XML-file?

查看:91
本文介绍了是否有可能从XML文件动态地改变资源?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望能够轻松地更改UI外观(颜色和放大器;标志)。一个应用程序,并认为问某人是否有关于如何最好地做到这一点的任何建议。

I want to easily be able to change the UI apperance (colors & logo) of an app and thought to ask if someone has any suggestions on how best to do it.

我要的是简单的编译,并(在colors.xml即颜色值),其具有的资源设置为XML的值之前更换项目的XML文件。
唯一的问题似乎是没有办法在运行时改变资源(?)

What I want is simply to replace an XML-file in the project before compiling it and having the resources (i.e. the color values in colors.xml) set to the values of the XML. The only problem seems to be that there is no way to change resources at runtime(?)

有没有在创作时自动更改资源的方法吗?

Is there any way of changing the resources automatically at authortime?

中只需更换XML文件不同的UI apperances整点是节省时间和减少编辑code的不同部分的金额。

The whole point of simply replacing the XML file for different UI apperances is to save time and minimize the amount of editing different parts of the code.

推荐答案

如果我明白你的问题正确的话,我想你想要的是主题化您的应用程序,我不知道你是否能在运行时不改资源,但你绝对可以有不同的主题,为每个UI组件,其中可以动态地应用。

If I understand your question correctly then I think all you want is Theming for your application, I do not know whether you can change Resources in runtime or not, but you can definitely have separate themes for each of your UI component, which you can apply dynamically.

在主题化具有很好的指导可以在这里找到:

A good guide on Theming can be found here:

http://brainflush.word$p$pss.com/2009/03/15/understanding-android-themes-and-styles/

尝试主题化,看看它是否适合你或没有。

Try the theming and see if it works for you or not.

感谢

这篇关于是否有可能从XML文件动态地改变资源?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆