> Hi, I have a horizontal LinearLayout in which I have a button, text1
> and text2. I want the button to be on the left, text2 on the right and
> text1 centered between them, like in the following diagram ( | is edge
> of the screen, - is empty space):
>
> | BUTTON-----------TEXT1------------TEXT2 |
>
>
> text1 and text2 can have different length based on language settings,
> so unfortunaely I cant hardcode the positions in pixels.

You would not want to hardcode the positions in pixels, anyway.

Do not use a LinearLayout for this. Use a RelativeLayout, something like
this:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android";
>
        <Button android:id="@+id/prev"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerVertical="true"
                android:layout_alignParentLeft="true"
        />
        <TextView android:id="@+id/next"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerVertical="true"
                android:layout_alignParentRight="true"
        />
        <TextView android:id="@+id/title"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerInParent="true"
                android:layout_toLeftOf="@id/next"
                android:layout_toRightOf="@id/prev"
        />
</RelativeLayout>

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com
Android App Developer Books: http://commonsware.com/books.html



--~--~---------~--~----~------------~-------~--~----~
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