How to set attributes in an android layout that is included in another layout?

I have a composite widget consisting of an ImageView object and a TextView wrapped inside a LinearLayout. Since this is used several times in one of my actions, I made it a separate layout and included it several times in the main layout. I understand that you can override the view identifier for the included layout from the tag in the main layout. My question is: is it possible to set things like image source and text from the main layout in XML? Of course, I could do it programmatically, but I was wondering if this is possible exclusively in XML ...

0
source share
1 answer

From the documentation :

You can include any other layout attributes in the <include> that are supported by the root element, including the layout, and they will override those defined in the root element.

It looks like you can override the layout_ * attributes. (One could tempt one to look at the source code to see if something else is kept secret, but it would be no-no in terms of advanced compatibility.)

0
source

Source: https://habr.com/ru/post/1397608/


All Articles