Tenho o seguinte layout
Eu quero que os botões estejam no fundo - todos os 3controles devem ser alinhados na parte inferior. (Agora eles estão no topo.) De acordo com a documentação (contanto que eu entenda), gravidade ou layout_gravity deve fazer o truque, mas eles não funcionam neste caso?
A seguir está o código. Por favor, qual é o problema?
<?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>
Respostas:
2 para resposta № 1remover android:gravity="bottom"
do pai LinearLayout.
1 para resposta № 2
Copie e cole este
<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"/>