Do you what’s the exact difference between gravity and layout_gravity attributes?
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.
Here is the best example that i came across: How to Position Views Properly in.
Here is my question on stackoverflow for the same: Android – gravity and layout_gravity