I want to use a number of ShapeDrawables in my application, which are all similar, but with different colours etc. Obviously I could just define them all in separate xml files, but is there a more efficient way to have one xml definition, instantiate various objects and change the colour either in code or xml? You could perhaps do this by calling mutate() on one ShapeDrawable defined in xml, but this returns a Drawable, rather than a shape drawable.
As far as I know (unless I'm missing something in the docs) that just enables you to add a colour gradient to your shapes - not quite what I was after.
Stev_k
2010-08-17 13:59:57
looks like one way to do it is using the setColorFilter(color, PorterDuff.Mode.Multiply) method on a single drawable defined in xml and inflated at runtime. For more info see http://stackoverflow.com/questions/1521640/standard-android-button-with-a-different-color
Stev_k
2010-09-04 22:31:19