J'ai la mise en page suivante
Je veux que les boutons soient en bas - tous 3les contrôles doivent être alignés en bas. (Maintenant, ils sont en haut.) Selon la documentation (pour autant que je le comprenne), la gravité ou la layout_gravity devraient faire l'affaire mais elles ne fonctionnent pas dans ce cas?
Voici le code. S'il vous plaît quel est le problème?
<?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="wrap_content"
android:orientation="horizontal"
android:gravity="bottom"
android:layout_gravity="bottom">
<Button
android:id="@+id/ButtonLeft"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:gravity="bottom"
android:layout_weight="1"
android:text="Show"/>
<TextView
android:id="@+id/Help"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="10"
android:gravity="center"
android:text="Very loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong text !"/>
<Button
android:id="@+id/ButtonRight"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_weight="1"
android:text="Show"/>
</LinearLayout>
Réponses:
2 pour la réponse № 1retirer android:gravity="bottom"
du parent LinearLayout.
1 pour la réponse № 2
Copiez et collez ceci
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_gravity="bottom">
<Button
android:id="@+id/ButtonLeft"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_weight="1"
android:text="Show"/>
<TextView
android:id="@+id/Help"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="10"
android:gravity="center"
android:text="Very loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong text !"/>
<Button
android:id="@+id/ButtonRight"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_weight="1"
android:text="Show"/>