0

I applied this custom-xml as TextView background.

It working as I expect. However, There are two shapes in this xml and I want to change color of these two shapes dynamically.

After searched, I didn't find any solution to solve this issue.

Any Idea? please advice, Thank.

<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
    <item>
        <rotate
                android:fromDegrees="0"
                android:toDegrees="0"
                android:pivotX="0%"
                android:pivotY="0%" >
            <shape
                    android:shape="rectangle" >
                <solid android:color="#ff0000" />
            </shape>
        </rotate>
    </item>
    <item>
        <rotate
                android:fromDegrees="-405"
                android:toDegrees="0"
                android:pivotX="0%"
                android:pivotY="100%" >
            <shape
                    android:shape="rectangle" >
                <solid android:color="#000000" />
            </shape>
        </rotate>
    </item>

</layer-list>
Jongz Puangput
  • 5,527
  • 10
  • 58
  • 96
  • Try: http://stackoverflow.com/questions/5940825/android-change-shape-color-in-runtime?rq=1 or http://stackoverflow.com/questions/16775891/how-to-change-solid-color-from-the-code?rq=1 or http://stackoverflow.com/questions/20463082/change-the-shape-color-in-an-android-xml?rq=1 – Ryan Clarke Jun 06 '14 at 12:21

1 Answers1

1

If you want to change color just once then you can have another custom-xml with the same shapes but with new color values and set the background of the textview to that xml dynamically.