When designing, for example, an TextView view
in Android, you can assign the properties android:layout_gravity="left"
and/orandroid:gravity="left"
What is the difference between using layout_gravity
or gravity
on the View
?
When designing, for example, an TextView view
in Android, you can assign the properties android:layout_gravity="left"
and/orandroid:gravity="left"
What is the difference between using layout_gravity
or gravity
on the View
?
The difference between them is that the
layout_gravity
is the gravity of the view with respect to its parent andgravity
is the internal gravity, for example if the view is aTextView
is where you want the text to be displayed, alignment etc...Image extracted from OS
It has already been answered in English: https://stackoverflow.com/questions/3482742/gravity-and-layout-gravity-on-android
I translate it for you: