That won't layout the TextView in the center of the LinearLayout. Instead, it will layout the text in the center of the TextView.
Visually, it looks the same though :) On Nov 12, 11:56 am, Kumar Bibek <[email protected]> wrote: > Use android:gravity="center_horizontal" instead of layout_gravity > > On Fri, Nov 12, 2010 at 10:24 PM, Streets Of Boston <[email protected] > > > > > > > wrote: > > Because your TextView's layout_width is set to fill_parent. > > Do 'wrap_content' instead, just like your Button's layout_width. > > > On Nov 12, 11:49 am, DulcetTone <[email protected]> wrote: > > > The following code incorrectly (in my view) places the text left- > > > justified, and the button is in the center, horizontally. Why is > > > this? > > > > <LinearLayout > > > android:layout_width="fill_parent" > > > android:layout_height="wrap_content" > > > android:layout_marginLeft="12dip" > > > android:layout_gravity="center_horizontal" > > > android:padding="6dip" > > > android:orientation="vertical" > > > android:background="@android:drawable/alert_light_frame" > > > > > <TextView > > > android:layout_marginTop="8dip" > > > android:textColor="#000000" > > > android:layout_gravity="center_horizontal" > > > android:text="This actually comes > > out left justified.. why?" > > > android:layout_width="fill_parent" > > > android:layout_height="wrap_content"/> > > > > <Button android:id="@+id/google_voice_button" > > > android:layout_gravity="center_horizontal" > > > android:layout_marginBottom="8dip" > > > android:textColor="#000000" > > > android:layout_width="wrap_content" > > > android:layout_height="wrap_content"/> > > > </LinearLayout> > > > -- > > 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]<android-developers%2bunsubs[email protected]> > > For more options, visit this group at > >http://groups.google.com/group/android-developers?hl=en > > -- > Kumar Bibekhttp://techdroid.kbeanie.comhttp://www.kbeanie.com- Hide quoted > text - > > - Show quoted text - -- 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

