Android: Changing colours via xml programmatically



I'm creating an app based around two teams, each of whom have a colour assigned. That colour is displayed at various points throughout the app and I want to give the user the choice to change the two colours that are used. At the moment, I have the two colours being used defined at follows:



<color name="colour_a">@color/pink</color>
<color name="colour_b">@color/blue</color>


which allows me to change one parameter and the entire app will adjust accordingly. My question is whether it is possible to change these definitions upon a change in the preferences. I could set all of the colours manually, but alot of the references to colour_a and colour_b are within drawable xml files which I can't change as easily (barring creating a separate drawable for every colour). Any suggestions on how to achieve this would be much appreciated!


No comments:

Post a Comment