views:

786

answers:

2

I'm curious about the <merge> and <include> tags in Android XML-layouts. I've read two tutorials, but haven't yet found a simple example usage.

Would be happy if someone could provide such an example or give a pointer to one.

+6  A: 

some_activity.xml:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent" android:layout_height="fill_parent"
    android:orientation="vertical">

    // some views

    <include layout="@layout/view_part"/>

   // probably more views

</LinearLayout>

view_part.xml:

<merge xmlns:android="http://schemas.android.com/apk/res/android"&gt;

    // the views to be merged

</merge>
alex
so the merge-thingy is referred to by its file-name... no id-attribute in the merge-file?
aioobe
@aioobe right. `<include>` basically means 'take that file and paste it's contents here'.
alex
A: 

id doesn't paste code otherwise relative layout parameters would have worked. It does some different processing

dev