Reputation: 149
I would like to do the button layout in the following format. I've tried relative layout, I've tried linear layout, I've tried table layout, but it all fails me..
Can someone guide me?
code:
<TableRow
android:id="@+id/tableRow12"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<Button
android:id="@+id/updateBTN"
style="@style/ButtonInside"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="50dp"
android:paddingTop="100dp"
android:text="Update" />
<Button
android:id="@+id/deleteBTN"
style="@style/ButtonInside"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingTop="100dp"
android:text="Delete" />
<Button
android:id="@+id/cancelBTN"
style="@style/ButtonInside"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingTop="100dp"
android:text="Cancel" />
</TableRow>
Upvotes: 1
Views: 2083
Reputation: 3099
You should use a combination of RelativeLayout
and LinearLayout
:
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentBottom="true"
android:orientation="horizontal"
android:weightSum="3.0"
>
<Button
android:id="@+id/btn1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1.0"
/>
<Button
android:id="@+id/btn2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1.0"
/>
<Button
android:id="@+id/btn3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1.0"
/>
<LinearLayout/>
<RelativeLayout/>
Upvotes: 0
Reputation: 38098
This layout
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:orientation="horizontal"
>
<Button
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Button 1"
/>
<Button
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Button 2"
/>
<Button
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Button 3"
/>
</LinearLayout>
</RelativeLayout>
gives this result:
Upvotes: 1
Reputation: 5295
Create a linearlayout with weightsum 90 and orientation horizontal and in it add three buttons with equal weights and ofcourse as per your image, you need to give each button a fixed width
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum=90>
<Button
android:layout_width="wrap_content" <!-- Or give a fixed width to all of your buttons -->
android:layout_height="wrap_content"
android:weight=30/>
<Button
android:layout_width="wrap_content" <!-- Or give a fixed width to all of your buttons -->
android:layout_height="wrap_content"
android:weight=30/>
<Button
android:layout_width="wrap_content" <!-- Or give a fixed width to all of your buttons -->
android:layout_height="wrap_content"
android:weight=30/>
</LinearLayout>
Upvotes: 0
Reputation: 8826
<RelativeLayout
android:height:"match_parent"
android:width:"match_parent">
<LinearLayout
android:orientation="horizontal"
android:alignParentBottom ="true">
<Button>
<Button>
<Button>
</LinearLayout>
</RelativeLayout>
linearlayout inside a relative layout will solve the issue.
Upvotes: 0