Hi I have a shape drawable in xml and it is used as background of a view. Its color needs to be changed in the code depending on conditions.
So I am doing
ShapeDrawable d = (ShapeDrawable) getResources().getDrawable(R.drawable.shape1);
d.getPaint().setShader(sd1);
but the getDrawable returns a gradient drawable, casting it to ShapeDrawable generates error.
So how can I get shapeDrawable in code and modify its attributes.