Difference between gravity and layout_gravity

#1

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

Thanks.

#2

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.

#3

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

http://www.technotalkative.com/android-difference-between-gravity-and-layout_gravity/

https://www.mindstick.com/forum/23256/difference-between-gravity-and-layout_gravity-on-android