comment insérer mise à disposition dans android?
J'ai deux dispositions de la première et de la seconde, je veux insérer deuxième à la première.
Je veux insérer une deuxième mise en page qui en a id @+id/mise en page
lorsque j'appuie sur le bouton Obtenir la Mise en page, c'est montrer la deuxième disposition sur le bas du bouton
premier schéma de
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<Button
android:id="@+id/btn_get_layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Get Layout" />
<LinearLayout
android:id="@+id/layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
</LinearLayout>
</LinearLayout>
deuxième disposition
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/card_base"
android:orientation="vertical" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent" >
<ImageView
android:id="@+id/img_cover"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_margin="10dp"
android:scaleType="fitXY"
android:src="@drawable/card_beauty" />
<ImageView
android:id="@+id/img_photo"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_margin="20dp"
android:scaleType="fitXY"
android:src="@drawable/sample_0" />
</RelativeLayout>
</LinearLayout>
Vous devez vous connecter pour publier un commentaire.
si j'ai bien compris vous avez droit, vous devez utiliser le code suivant dans votre premier schéma de
et puis dans le bouton d'action, il suffit d'utiliser
Utilisation
include
Ici est un peu plus complète exemple. Le carré bleu mise en page est insérée dans la page principale à l'aide de
include
.activity_main.xml
C'est la page principale. La mise en page personnalisée est référencée à l'aide
include
. Vous pouvez remplacer tous les attributs ici, trop.my_layout.xml
C'est la mise en page personnalisée qui sera inséré dans la page principale.
Utilisation LayoutInflator pour gonfler un modèle externe en page existante. La caisse LayoutInflater sur Android Dev Site pour plus d'informations à ce sujet.
Vous Devez utiliser ce bout de code à ajouter une Mise en page à l'intérieur d'un autre.
Ici la
parentLayout
est la racine de la Vue etR.layout.view_video
est la mise en page que vous devez insérer.