How to modify the childs text from a merge layout from the include xml tag?
I want to somehow modify the content of the merge layout from the include tag. Is that possible?
Layout picAndText.xml:
<merge xmlns:android="http://schemas.android.com/apk/res/android">
<ImageView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scaleType="center"
android:src="@drawable/golden_gate" />
<TextVi开发者_开发问答ew
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="20dip"
android:layout_gravity="center_horizontal|bottom"
android:padding="12dip"
android:background="#AA000000"
android:textColor="#ffffffff"
android:text="Golden Gate" />
</merge>
And the layout xml that uses picAndText.xml:
<include layout="@layout/picAndText" android:id="@+id/picText" />
Please note this is an example of what I would like to acomplish. I want to reuse complex layouts with multiple children but I need different text on them every time I reuse these without having to copy the whole layout everywhere...
Thanks! -Jona
If I understand what you are trying to do correctly, I don't think its possible from XML. Instead, you can update the text when you load the layout in code.
精彩评论