Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android: include a xml into an other xml

Tags:

How to include a xml data into an other xml data?

I have a header xml-file for my application which I want to use in my special other content xmls. Is there a ways to include the header into my content?

like image 945
Xetoxyc Avatar asked Jun 10 '11 13:06

Xetoxyc


People also ask

How do I insert one XML file into another Android?

Probably you will have to set within the include tag the properties that sets where it has to be placed: android:layout_above, android:layout_toLeftOf, etc... Use fill_parent instead. I pasted my code and I am working with honeycomb, thats why I was using match_parent. But it should work with fill_parent.

Is it possible to include one layout definition in another?

To efficiently re-use complete layouts, you can use the <include/> and <merge/> tags to embed another layout inside the current layout. Reusing layouts is particularly powerful as it allows you to create reusable complex layouts. For example, a yes/no button panel, or custom progress bar with description text.

Is XML still used in Android?

XML is often used in front-end web development. It's also is used in back-end web development because some APIs use it to transfer data in a standard format. Android applications also depend heavily on XML to create layouts and store configurations, so you should learn XML if you're interested in mobile development.


1 Answers

use include tag

<?xml version="1.0" encoding="utf-8"?> <RelativeLayout     xmlns:android="http://schemas.android.com/apk/res/android"          android:layout_width="fill_parent"     android:layout_height="fill_parent"  >   <!-- Header -->   <include     android:id="@+id/container_header_lyt"       android:layout_height="wrap_content"     android:layout_width="fill_parent"     android:layout_above=...     android:layout_toLeftOf=...     layout="@layout/header_logo_lyt" //Name of the xml layout file you want to include     />       ...  </RelativeLayout> 
like image 176
Axel M. Garcia Avatar answered Nov 03 '22 00:11

Axel M. Garcia