Is it possible to set the background of Drawable to a Drawable class name in XML?
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.
精彩评论