Saturday, 3 January 2015

Save color values in theme variables and reference them in activty xml?



I want to provide different app themes for my users to chose from. What I want to do is to define a Color1 and Color2 in my theme and reference these colors in the activies my xml.


Something like:



<style name="Theme.LightTheme" parent="Theme.General">
<item name="android:color1">#000000</item>
<item name="android:color2">#ffffff</item>
</style>


And then on an activity xml:



<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="?android:color1"
android:background="?android:color2" />


How can this be done?


No comments:

Post a Comment