The inner LinearLayout has its width set to "fill_parent" so you are
trying to center something that is full width.
Try:

        <LinearLayout android:orientation="horizontal"
                      android:layout_width="fill_parent"
                      android:layout_height="wrap_content"
                      android:gravity="center_horizontal">
                <LinearLayout android:orientation="horizontal"
                              android:layout_width="wrap_content"
                              android:layout_height="wrap_content">
                        <TextView android:layout_width="wrap_content"
 
android:layout_height="wrap_content"
                                  android:text="Name: "
                                  android:paddingRight="4px"/>
                        <TextView android:id="@+id/Name"
                                  android:layout_width="wrap_content"
 
android:layout_height="wrap_content"
                                  android:text="Fred"/>
                </LinearLayout>
        </LinearLayout>

Keean.

On Sep 3, 8:21 am, sdphil <[email protected]> wrote:
> i am trying to create some text like this:
>
> +=======================+
> |                                                |
> |              Name: Fred                 |
> |                                                |
> +=======================+
>
> and I want the combination of "Name: " and "Fred" to be horizontally
> centered.  The "Fred" TextView can change:
>
>         <LinearLayout android:orientation="horizontal"
>                       android:layout_width="fill_parent"
>                       android:layout_height="wrap_content"
>                       android:gravity="center_horizontal">
>
>                 <LinearLayout android:orientation="horizontal"
>                               android:layout_width="fill_parent"
>                               android:layout_height="wrap_content">
>
>                         <TextView android:layout_width="wrap_content"
>                                   android:layout_height="wrap_content"
>                                   android:text="Name: "
>                                   android:paddingRight="4px"/>
>
>                         <TextView android:id="@+id/Name"
>                                   android:layout_width="wrap_content"
>                                   android:layout_height="wrap_content"
>                                   android:text="Fred"/>
>
>                 </LinearLayout>
>
>         </LinearLayout>
>
> But it doesn't center - what am I missing?
>
> tia.
--~--~---------~--~----~------------~-------~--~----~
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