开发者

Is it possible to set the background of Drawable to a Drawable class name in XML?

开发者 https://www.devze.com 2023-03-28 08:49 出处:网络
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

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?


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消