What is the difference between android: layout_gravity and android: gravity?

4

When you design, for example, a TextView view in Android, you can assign the properties android:layout_gravity="left" and / or android:gravity="left"

What is the difference between using layout_gravity or gravity over View ?

    
asked by Pablo Ezequiel 05.07.2016 в 01:08
source

2 answers

5

The difference between them is that the layout_gravity is the severity of the view with respect to its parent and gravity is the internal severity, for example if the view is a TextView is where you want the text to be show, alignment etc ...

Image taken from SO

    
answered by 05.07.2016 / 08:29
source
2

It was already answered in English: link

I translate it to you:

  

Their names should help you:

     

android: gravity sets the severity of the content of the view in which it is used.        android: layout_gravity sets the severity of the FATHER of the view or layout.

     

Here is an example.

    
answered by 05.07.2016 в 08:18