I have the following drawable which I use as the background for a TextView:
<?xml version="1.0" encoding="utf-8" ?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item><shape android:shape="rectangle"><gradient android:centerX="0.5" android:centerY="0.5" android:centerColor="@color/White" android:startColor="@color/Red" android:endColor="@color/Red"/></shape></item>
<item><shape android:shape="rectangle"><gradient android:angle="90" android:centerX="0.5" android:centerY="0.375" android:centerColor="@color/Transparent" android:startColor="@color/Red" android:endColor="@color/Transparent"/></shape></item>
<item><shape android:shape="rectangle"><gradient android:angle="90" android:centerX="0.5" android:centerY="0.625" android:centerColor="@color/Transparent" android:startColor="@color/Transparent" android:endColor="@color/Red"/></shape></item>
</layer-list>
I need to programmatically edit the startColor, centerColor, and endColor of each of the GradientDrawable(s) in the LayerDrawable. I am able to access the GradientDrawable(s), but I cannot seem to figure out how to set the mentioned properties. Everything I have been able to find says to either use the SetColors method or create a new GradientDrawable. I have been unable to figure out how to do either of these. The values I will be using for the colors are color resources. How can I edit the GradientDrawable(s)?