Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

android xml drawable parameters

Is it possible to have an xml drawable with parameters? Suppose I have an xml drawable that I want to reuse for the rounded corners, gradients etc, and the only variable is a color or two. Is it possible to specify/pass parameters to an xml drawable?

like image 358
Ben Avatar asked Dec 06 '11 07:12

Ben


1 Answers

Perhaps you can derive your own class from Drawable, have a constructor accepting the parameters you want to make adjustable and in the constructor first call createFromXML passing your xml and then setup those adjustable parameters. I didn't try that myself, perhaps, I'm wrong

like image 71
Alexander Kulyakhtin Avatar answered Sep 21 '22 03:09

Alexander Kulyakhtin