I made a custom, multi-layered drawable to act as the background for a button. Sometimes, I want part of this drawable layer to be blue. Sometimes I want it to be green. Point is, it's a variable, and I want it to be definable in the associated custom view XML.
Is this possible? How do I write a drawable in XML whose value I can determine at runtime?
custom_button.xml
<?xml version="1.0" encoding="utf-8"?>
<inset xmlns:android="http://schemas.android.com/apk/res/android"
android:insetLeft="@dimen/button_inset_horizontal_material"
android:insetTop="@dimen/button_inset_vertical_material"
android:insetRight="@dimen/button_inset_horizontal_material"
android:insetBottom="@dimen/button_inset_vertical_material">
<shape android:shape="rectangle">
<corners android:radius="@dimen/control_corner_material" />
<solid android:color="?attr/colorButtonNormal" />
<padding android:left="@dimen/button_padding_horizontal_material"
android:top="@dimen/button_padding_vertical_material"
android:right="@dimen/button_padding_horizontal_material"
android:bottom="@dimen/button_padding_vertical_material" />
</shape>
</inset>
The line <solid android:color="?attr/colorButtonNormal" />
is what I want to set at runtime. I have my custom view for this class already receiving the color value I want to use here - how do I apply it to the XML of this drawable?