Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Simple example of <merge> and <include> usage in Android XML-layouts

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.

like image 809
aioobe Avatar asked Apr 28 '10 19:04

aioobe


People also ask

What is use of merge in Android XML?

Merge Tag. The <merge /> tag helps us to eliminate redundant view groups in our view hierarchy when including one layout within another.

What is layout explain its usage in Android with a suitable example?

Android Layout TypesTableLayout is a view that groups views into rows and columns. AbsoluteLayout enables you to specify the exact location of its children. The FrameLayout is a placeholder on screen that you can use to display a single view. ListView is a view group that displays a list of scrollable items.

What is include in Android XML?

In Android, for reusing the complete layouts we can use the <include/> and <merge/> tags to embed another layout inside the current layout. Android offers a variety of widgets to provide small and reusable interactive elements.

What is the purpose of the include tag *?

The include tag The <include> tag lets you to divide your layout into multiple files: it helps dealing with complex or overlong user interface. Then you need to write include1.


1 Answers

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">      // the views to be merged  </merge> 
like image 53
yanchenko Avatar answered Oct 18 '22 20:10

yanchenko