Difference between gravity and layout_gravity


Chapter one used gravity and chapter 2 have used layout_gravity. My question is, what’s the difference between them?



Ah! This is an error in the book - the android:gravity attribute does nothing in chapter 1.

The android:gravity attribute is used on TextView. It tells the TextView where within itself it should place its text. layout_gravity, on the other hand, is an instruction to a parent layout - usually a FrameLayout, sometimes a LinearLayout.


Hi check this useful and helpful link about difference between gravity and layout gravity.I hope it will help you