Reputation: 11
<TableLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/TableLayout01"
android:layout_height="wrap_content" android:layout_width="fill_parent">
<TableRow android:id="@+id/TableRow01" android:layout_width="wrap_content"
android:layout_height="wrap_content">
<Button android:layout_width="wrap_content"
android:layout_height="wrap_content" android:text="Settings"
android:id="@+id/btnSettings"></Button>
<Button android:text="@+id/Button01" android:id="@+id/Button01"
android:layout_width="wrap_content" android:layout_height="wrap_content"></Button>
</TableRow>
<TableRow android:id="@+id/TableRow02" android:layout_width="wrap_content"
android:layout_height="wrap_content">
<Button android:text="@+id/Button03" android:id="@+id/Button03"
android:layout_width="wrap_content" android:layout_height="wrap_content"></Button>
<Button android:text="@+id/Button04" android:id="@+id/Button04"
android:layout_width="wrap_content" android:layout_height="wrap_content"></Button>
</TableRow>
</TableLayout>
please give suggestions,whether the code is right or wrong???
Upvotes: 0
Views: 1709
Reputation: 535
So close!
First you need to put the whole table layout in the following view. This can be your root view if you want
<RelativeLayout android:layout_width="fill_parent" android:id="@+id/relativeLayout1" android:layout_height="fill_parent">
Then just ad to your table layout the following atribute:
android:layout_centerInParent="true"
And finally change in the table layout android:layout_width="fill_parent"
to android:layout_width="wrap_content
"
Easy!
Upvotes: 3