sdphil wrote:
> I have this xml --
> 
>     <LinearLayout android:orientation="horizontal"
>                     android:layout_centerVertical="true"
>                   android:layout_width="fill_parent"
>                   android:layout_height="35px">
> 
>               <ImageButton android:id="@+id/Btn1"
>                            android:layout_width="wrap_content"
>                            android:layout_height="fill_parent"
>                            android:src="@drawable/btn1"
>                            android:background="@color/transparent"/>
> 
>               <TextView android:id="@+id/Text1"
>                     android:layout_width="fill_parent"
>                     android:layout_height="wrap_content"
>                     android:layout_gravity="center_horizontal"
>                     android:layout_centerHorizontal="true"
>                     android:background="@color/red"
>                     android:text="Text1"/>
> 
>       </LinearLayout>

Use android:gravity="center_horizontal".

First, android:layout_centerHorizontal="true" is only valid if the
parent is a RelativeLayout, and in your case, you are using LinearLayout.

Second, android:layout_gravity="center_horizontal" might work, if you
used android:layout_width="wrap_content". Since you used
android:layout_width="fill_parent", you are saying that the TextView is
to fill up all remaining space in the row, so there is nothing to be
centered. If you use the hierarchyviewer tool, you will see this effect
in the wireframe diagram in the lower right.

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

Need Android talent? Ask on HADO! http://wiki.andmob.org/hado

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