开发者

Can I use a static variable from a Java class in res/values/styles.xml?

I want to refer to a static Java variable in my styles.xml, is that possible? Here's a pseud开发者_Python百科o-xml example:

<style name="Artwork">
    <item name="android:background">@drawable/border_{Constants.MY_COLOR}</item>
</style>


This isn't possible. The styles.xml is compiled into a block of data available to your app, and there is no provision whatsoever to cross-reference Java elements at build or runtime.

However you will be able to programatically modify the background color of the relevant elements at runtime as they are inflated in your Java class.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜