0
我將此custom-xml作爲TextView背景應用。Android:動態更改XML中的形狀顏色
它按照我的預期工作。但是,這個XML中有兩種形狀,我想動態改變這兩種形狀的顏色。
經過搜索,我沒有找到任何解決方案來解決這個問題。
任何想法?請諮詢,謝謝。
<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>
嘗試:http://stackoverflow.com/questions/5940825/android-change-shape-color-in-runtime?rq=1或http://stackoverflow.com/questions/16775891/how-to-change -solid-color-from-the-code?rq = 1或http://stackoverflow.com/questions/20463082/change-the-shape-color-in-an-android-xml?rq=1 –