Para esclarecer o uso de <include> e <merge>

Só preciso que alguém me diga se entendi corretamente quando usar<include> e quando<merge>.

ntão, faço um layout de cabeçalho que quero incluir em outro layout XM

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
           <TextView
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content"        
        android:text="Header text" />
</LinearLayout>

E incluí-lo em outro XML desta maneira (o que é bastante básico):

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent">
               <include android:id="@+id/header" layout="@layout/top"
             android:layout_width="fill_parent" android:layout_height="wrap_content"
            />
</LinearLayout>

Isso funcionará bem, não há problema. Mas, para otimizar o código, tenho que usar<merge> no layout que é incluído. Então otop layout não deve ter uma tag<LinearLayout>, mas deve ser assim:

<merge xmlns:android="http://schemas.android.com/apk/res/android">
     <TextView
            android:layout_width="wrap_content" 
            android:layout_height="wrap_content"        
            android:text="Header text" />
</merge>

Entendi isso corretamente?

questionAnswers(4)

yourAnswerToTheQuestion