gravity and android:gravity

This question already has an answer here:

  • Difference between gravity and layout_gravity on Android 19 answers

  • android:layout_gravity是与整个Layout相似的重力,比如LinearLayout,Relative layout和android:gravity是与你的特定视图相关的重力,比如Button,EditText android:layout_gravity希望这有助于


    android:gravity sets the gravity of the content of the View its used on.

    android:layout_gravity sets the gravity of the View or Layout in its parent.

    go through this example


    android:gravity applies graivity to the content of the view, while android:layout_gravity applies gravity to the view itself inside its parent.

    For a button,layout_gravity will apply gravity to whole button whereas android:gravity will apply to its content that is text on Button etc.

    链接地址: http://www.djcxy.com/p/93304.html

    上一篇: 重力和布局之间的差异

    下一篇: 重力和android:重力