Reputation: 151
so I have an layout that includes:
<RelativeLayout
android:id="@+id/footer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true">
<Button
android:id="@+id/ButtonOK"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Go"
style="@style/btnStyleBreakerBay"/>
<Button
android:id="@+id/ButtonAll"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="See All"
android:layout_toRightOf="@+id/ButtonOk"
style="@style/btnStyleBreakerBay"/>
<Button
android:id="@+id/ButtonBack"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Back"
android:layout_toRightOf="@+id/ButtonAll"
style="@style/btnStyleBreakerBay"/>
</RelativeLayout>
What I want is all 3 buttons going across the bottom but only ButtonBack and ButtonAll are showing up but not taking up the whole bottom. Could someone help me figure out what I am doing wrong?
Thank you in advance, Tyler
Upvotes: 0
Views: 58
Reputation: 11359
<LinearLayout
android:weightSum="3"
android:id="@+id/footer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true">
<Button
android:id="@+id/ButtonOK"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Go"
style="@style/btnStyleBreakerBay"/>
<Button
android:id="@+id/ButtonAll"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="See All"
android:layout_toRightOf="@+id/ButtonOK"
style="@style/btnStyleBreakerBay"/>
<Button
android:id="@+id/ButtonBack"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Back"
android:layout_toRightOf="@+id/ButtonAll"
style="@style/btnStyleBreakerBay"/>
</LinearLayout>
Set the lay out orientation based on your choice. Use android:orientation="vertical"
or
android:orientation="horizontal"
Upvotes: 2
Reputation: 4255
Try this one :
<RelativeLayout
android:id="@+id/footer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true">
<Button
android:id="@+id/ButtonAll"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="See All"
android:layout_toRightOf="@+id/ButtonOk"
style="@style/btnStyleBreakerBay" />
<Button
android:id="@+id/ButtonBack"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Back"
android:layout_toRightOf="@+id/ButtonAll"
style="@style/btnStyleBreakerBay"/>
<Button
android:id="@+id/ButtonOK"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_toRightOf="@+id/ButtonBack"
android:layout_weight="1"
android:text="Go"
style="@style/btnStyleBreakerBay" />
</RelativeLayout>
Upvotes: 0
Reputation: 1803
Use this Your edited Code
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/footer"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true" >
<Button
android:id="@+id/ButtonOK"
style="@style/btnStyleBreakerBay"
android:layout_width="0px"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Go" />
<Button
android:id="@+id/ButtonAll"
style="@style/btnStyleBreakerBay"
android:layout_width="0px"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="See All" />
<Button
android:id="@+id/ButtonBack"
style="@style/btnStyleBreakerBay"
android:layout_width="0px"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Back" />
</LinearLayout>
</RelativeLayout>
hope this helps
Upvotes: 2
Reputation: 152817
There are two overdrawn buttons. There's ButtonOK
and then a rule with non-existing target android:layout_toRightOf="@+id/ButtonOk"
(notice the lowercase k
in Ok
). This makes the "All" button to draw over the "Ok" button.
To make them appear side-to-side, change the ids to match each other.
To make the buttons be of equal size and take up all horizontal space, change the RelativeLayout
to a LinearLayout
and change the button widths to 0px
, removing the layout_toRightOf
rules that are only valid in a RelativeLayout
.
(Note that layout_weight
only works in a LinearLayout
.)
Upvotes: 1