Step #1: Get rid of the LinearLayout, since you do not appear to need it

Step #2: Get rid of the android:orientation="horizontal" from the
RelativeLayout, since orientation is not a valid attribute for
RelativeLayout

Step #3: Give your first Button an android:id value, so we can refer
to it from within the XML

Step #4: Have your middle Button anchor itself to the other two
(android:layout_toRightOf="..." and
android:layout_toLeftOf="@+id/btnLocate")

Step #5: Remove the + sign from @+id/btnLocate in the last Button,
since ideally you only use the + sign on the first occurrence of the
ID value in the layout file, and step #4 refers to btnLocate first

On Tue, Oct 19, 2010 at 8:11 AM, Laurent Lugon Moulin
<[email protected]> wrote:
> Hi all,
>
> I want to put three buttons in one single line with the left and the right
> button at a fixed size, and the middle button wich take the distance between
> the two buttons. My application will work in different device, so I can't
> fix the size, it has to be adaptative...
>
> Here is my current code :
>
> <RelativeLayout android:layout_height="wrap_content"
>         android:layout_width="fill_parent"
>         android:orientation="horizontal"
>         android:gravity="center">
>
>             <Button android:layout_width="70dp"
>                 android:layout_height="wrap_content"
>                 android:text="@string/lbl_help"
>                 android:gravity="center"
>                 android:background="@drawable/btn_grey_9p"
>                 android:textColor="#cccccc"
>                 android:textSize="18dp"
>                 android:layout_margin="1dp"
>                 android:layout_alignParentLeft="true"/>
>
>             <LinearLayout android:layout_height="wrap_content"
>                 android:layout_width="wrap_content"
>                 android:gravity="center"
>                 android:layout_centerInParent="true">
>
>                 <Button android:id="@+id/btnApply"
>                     android:layout_width="140dp"
>                     android:layout_height="wrap_content"
>                     android:text="@string/protect_me"
>                     android:gravity="center"
>                     android:background="@drawable/btn_bottom"
>                     android:textColor="#ffffff"
>                     android:textStyle="bold"
>                     android:textSize="18dp"
>                     android:layout_marginTop="1dp"/>
>             </LinearLayout>
>
>             <Button android:id="@+id/btnLocate"
>                 android:layout_width="70dp"
>                 android:layout_height="wrap_content"
>                 android:gravity="center"
>                 android:background="@drawable/btn_bottom"
>                 android:textColor="#ffffff"
>                 android:textSize="18dp"
>                 android:text="@string/btn_locate"
>                 android:layout_margin="1dp"
>                 android:layout_alignParentRight="true"/>
>
>     </RelativeLayout>
>
> For the moment, the size is fixed (in red in the code). If I use a
> LinearLayout, with the middle button widht parameter :
> 'android:layout_width="fill_parent"' It start at the right of the left
> button (OK) but overwrite the right button (NOT OK)
>
> Anyone can help me ?
>
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en



-- 
Mark Murphy (a Commons Guy)
http://commonsware.com | http://github.com/commonsguy
http://commonsware.com/blog | http://twitter.com/commonsguy

Android App Developer Books: http://commonsware.com/books

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to