androidxmlandroid-xml

Using a variable in android XML or otherwise programmatically setting an XML attribute


Say I have a style that I want to change:

<?xml version="1.0" encoding="utf-8"?>
<resources>
<style parent="Widget.TitlePageIndicator" name="Widget.MyTitlepageIndicator">
    <item name="footerColor">#14A804</item>
</style>
</resources>

And I want to change the value of "footerColor", more specifically cycle through the spectrum. Is this possible? How would I obtain a reference to that memory address?


Solution

  • As far as I know, you can't change the value within this resource file. That is the whole point of a resource file, having a static resource that does not change.

    What you can do is have multiple definitions of different styles in this resource file, and change the style that is being applied to a layout element.

    That can be done using this answer.