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>
1

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.