<?xml version="1.0" encoding="utf-8"?> <layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <item android:id="@android:id/background"> <shape> <solid android:color="#FF0000" /> </shape> </item> <item android:id="@android:id/progress"> <clip> <shape> <solid android:color="#00FF00" /> </shape> </clip> </item> </layer-list>
This Drawable I am applying on Seekbar. I have to access this Drawable in Code and change its "background"/"progress" Color.
But really I don't have any idea that how can I access it in a Code.
Please help me to do this.
EDIT
LayerDrawable ld = (LayerDrawable) getResources().getDrawable(R.drawable.my_drawable);
ClipDrawable cd = (ClipDrawable) ld.getDrawable(1);
cd.setColorFilter(0xFFFF0000, PorterDuff.Mode.MULTIPLY);