I have the following file in my drawable folder called /drawable/mybkg.xml
. I want to inflate it so I can change the colors programmatically. Is that possible in Android?
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item>
<shape android:shape="oval" >
<padding
android:top="5dp"
android:bottom="2dp"
android:left="2dp"
android:right="2dp" />
<solid
android:angle="270"
android:color="#1bd4f6" />
<stroke
android:width="2dp"
android:color="#121ce5" />
</shape>
</item>
<!-- Foreground -->
<item>
<shape android:shape="oval" >
<solid android:color="#1b90f6" />
</shape>
</item>
</layer-list>
I just now saw a class called LayerDrawable
. Does anyone know how I could convert my xml file into such a LayerDrawable
either by writing the code or inflating the existing xml?