I've a Drawable xml file (background.xml):
<?xml version="1.0" encoding="UTF-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item>
<shape>
...........
</shape>
</item>
<item android:id="@+id/shape_id">
<shape android:shape="rectangle">
<solid android:color="#ffefefef" />
</shape>
</item>
</layer-list>
used by a LinearLayout:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:background="@drawable/background"
android:id="@+id/layout_id"
>
Now i need to change the shape shape_id
solid color at runtime based on some conditions. How to do this?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…