What is the difference between gravity and layout_gravity in Android?

前端 未结 20 1153
庸人自扰
庸人自扰 2020-11-21 11:41

I know we can set the following values to the android:gravity and android:layout_gravity properties:

    <
20条回答
  •  情书的邮戳
    2020-11-21 12:33

    Something I saw on Sandip's blog that I almost missed, fixed my problem. He said layout_gravity DOES NOT WORK WITH LinearLayout.

    If you're using a LinearLayout and the gravity settings are driving you nuts (like me), then switch to something else.

    I actually switched to a RelativeLayout then used layout_alignParentLeft and layout_alignParentRight on the 2 contained TextViews to get them on one line to go far left and far right.

提交回复
热议问题