Ben
Ben

Reputation: 16534

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?

Upvotes: 8

Views: 1330

Answers (1)

Alexander
Alexander

Reputation: 48272

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

Upvotes: 2

Related Questions