是否可以将可绘制的背景设置为XML中的可绘制类名称?
continue
I found some code in our project where someone is iterating over the children of a ViewGroup
so they can set a custom Java-based drawable as the background. I'd like to clean that up a bit by setting the background drawable in our layout XML files.
Is there a way to specify a Java class to use as the background via the XML layout definition?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
I think you can reference the java class by specifying it's full path (i.e. its package).
For instance, com.example.android.yourClass.
环顾四周后,我无法找到一种方法来做到这一点。我必须在代码中指定背景可绘制对象。
After looking around quite a bit I was unable to find a way to do this. I had to specify the background drawable in code.