views:

34

answers:

1

I want to refer to a static Java variable in my styles.xml, is that possible? Here's a pseudo-xml example:

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

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.

Jim Blackler