tags:

views:

305

answers:

2
<RelativeLayout
    android:layout_width="fill_parent"
    android:layout_height="50dip">
    <Button
        android:text="Edit"
        android:width="50dip"
        android:layout_height="fill_parent"
        android:layout_width="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true" />
    <ToggleButton
        android:textOn="All"
        android:textOff="Wishlist"
        android:layout_height="fill_parent"
        android:layout_width="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_alignParentTop="true" />
    <Button 
        android:text="+"
        android:width="50dip"
        android:layout_height="fill_parent"
        android:layout_width="wrap_content"
        android:layout_alignParentRight="true"
        android:layout_alignParentTop="true" />
</RelativeLayout>

http://i50.tinypic.com/15qadd2.jpg

I have these three buttons I want to align them in a similar fashion to the iphone version. I've tried using gravity and things but I can't seem to get them to look the same without absolute positioning.

Thanks

So I figured it out. I replaced my original code with the solution if any one happens to need it.

A: 

I would personally use a TableLayout to accomplish that.

mbaird
Thanks for the suggestion. I figured there was a way to accomplish this without extending the view hierarchy with more viewgroups then needed.
Jared
A: 

I was able to get pretty close with this layout:

<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="50dip">

    <Button
        android:text="Edit"
        android:width="50dip"
        android:layout_width="wrap_content"
        android:layout_height="fill_parent"
        android:layout_alignParentLeft="true"/>

    <ToggleButton
        android:text="Toggle"
        android:textOn="All"
        android:textOff="Wishlist"
        android:layout_width="wrap_content"
        android:layout_height="fill_parent"
        android:layout_centerHorizontal="true"/>

    <Button
        android:text="+"
        android:width="50dip"
        android:layout_width="wrap_content"
        android:layout_height="fill_parent"
        android:layout_alignParentRight="true"/>
</RelativeLayout>
Erich Douglass
Your answer is similar to my solution. Thanks for the nudge to the correct solution.
Jared