Reputation: 7053
I want 2 buttons to appear in the center of the screen, but at the bottom of the screen..
Here is what I have so far.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TableLayout android:layout_width="match_parent"
android:id="@+id/tableLayout2"
android:layout_gravity="center"
android:layout_height="fill_parent"
android:stretchColumns="@string/app_name">
<TableRow android:id="@+id/tableRow1"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<Button android:text="History"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_width="fill_parent"
android:id="@+id/button1"
></Button>
<Button android:text="RecordSpending"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:id="@+id/button2"
android:gravity="center_vertical"></Button>
</TableRow>
</TableLayout>
</LinearLayout>
I want this whole layout to appear at the bottom of the screen..(no matter what phone resolution the user has)..
I want the two columns to be equal in size and the bottoms located in the center horizontally.
Upvotes: 0
Views: 197
Reputation: 7708
To put two buttons at the bottom of the screen you can do this, psuedo code add relevant attributes.
<!-- This is the parent layout -->
<RelativeLayout
android:layout_height="fill_parent"
android:layout_width="fill_parent" >
<!-- Layout for your buttons at bottom -->
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:layout_alignParentBottom="true">
<!-- weight = 1 would mean both buttons are of equal width -->
<Button
android:layout_height="wrap_parent"
android:layout_width="0dp"
android:layout_weight="1.0" />
<Button
android:layout_height="wrap_parent"
android:layout_width="0dp"
android:layout_weight="1.0" />
</LinearLayout>
</RelativeLayout>
Upvotes: 3