I have the following code, how do I make it so that the 3 buttons are at the bottom?
<TextView
android:id="@+id/textView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="60dp"
android:gravity="center"
android:text="@string/observer"
android:textAppearance="?android:attr/textAppearanceLarge"
tools:context=".asdf"
android:weight="1" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<Button
android:id="@+id/button1"
style="?android:attr/buttonStyleSmall"
android:layout_width="145dp"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal|center"
android:text="1" />
<Button
android:id="@+id/button2"
style="?android:attr/buttonStyleSmall"
android:layout_width="145dp"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal|center"
android:text="2" />
<Button
android:id="@+id/button3"
style="?android:attr/buttonStyleSmall"
android:layout_width="145dp"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal|center"
android:text="3" />
</LinearLayout>
You need to ensure four things:
LinearLayouthaslayout_height="match_parent"LinearLayouthaslayout_weight="1"andlayout_height="0dp"TextViewhaslayout_weight="0"LinearLayout: android:gravity="center|bottom"Notice that
fill_parentdoes not mean “take up all available space”. However, if you uselayout_height="0dp"withlayout_weight="1", then a view will take up all available space (Can't get proper layout with "fill_parent").Here is some code I quickly wrote up that uses two LinearLayouts in a similar fashion to your code.
The result looks like similar to this: