What is the difference between gravity and layout_gravity in Android?

Their names should help you:

  • android:gravity sets the gravity of the contents (i.e. its subviews) of the View it’s used on.
  • android:layout_gravity sets the gravity of the View or Layout relative to its parent.

And an example is here.

Leave a Comment