Textview Gravity not working properly in android

后端 未结 5 831
没有蜡笔的小新
没有蜡笔的小新 2021-02-13 18:44

What\'s wrong with my code, I\'m trying to display my TextView named \"invalid\", in different locations (left,right,center), but the gravity (left,right,center) w

5条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-02-13 19:46

    99% of the time, not working properly == not used properly.

    You are mistaking gravity and layout_gravity.

    gravity is the way the text will align itself in the TextView. The TextView being in wrap_content this does nothing, as the TextView is exactly the size of the text.

    layout_gravity is the way the TextView will align itself in its parent, in your case in the vertical LinearLayout

提交回复
热议问题