android xml drawable parameters

你。 提交于 2019-12-10 13:05:39

问题


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?


回答1:


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



来源:https://stackoverflow.com/questions/8396779/android-xml-drawable-parameters

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!