How to set attributes inside Android layout that is included in another layout?
I have a composite widget that consists of an ImageView and TextView object wrapped up inside a LinearLayout. Since this is used several times inside one of my activities I made it a separate layout and include it multiple times inside the main layout. I understand you can override the view id for the included layout from the tag in the main layout. My question is, is it possible to set things li开发者_如何学Cke the image source and textview string from the main layout in XML? Sure, I could do this programmatically but I was wondering if it was possible purely in XML...
From the documentation:
You can include any other layout attributes in the <include> that are supported by the root element in the included layout and they will override those defined in the root element.
It sounds like you can only override the layout_* attributes. (One might be tempted take a look at the source code to see if something else is secretly supported, but that would be a no-no in terms of forward compatibility.)
精彩评论