Android: inclure un xml dans un autre xml
-
26-10-2019 - |
Question
Comment inclure des données XML dans un autre données xml
J'ai un fichier xml-header pour mon application Wich je veux utiliser dans mes autres xmls de contenu spécial est-il une des façons d'inclure l'en-tête dans mon contenu?
La solution
utilisation comprennent balise
<?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>
Autres conseils
Vous devez déclarer votre mise en page xml « body » avec une
<?xml version="1.0" encoding="utf-8"?>
<merge>
<ImageView android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scaleType="center"
android:src="@drawable/image" / >
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal|bottom"
android:background="#AA000000"
android:textColor="#ffffffff"
android:text="Some Text" / >
</merge>
Ceci est le contenu de votre
Vous devez utiliser
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow