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?
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.
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.
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.
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>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With