views:

343

answers:

2

Hello all,

I know we can set the following value to the anroid:gravity and android:layout_gravity :

  1. center
  2. center_vertical
  3. center_horizontal , etc.

But i am confused regarding these both.

what is the difference between the usage of android:gravity and android:layout_gravity?

+2  A: 

Their name should help you :
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.
And an example : http://thinkandroid.wordpress.com/2010/01/14/how-to-position-views-properly-in-layouts/

Sephy
+1  A: 

From what I can gather layout_gravity is the gravity of that view inside its parent, and gravity is the gravity of the children inside that view.

I think this is right but the best way to find out is to play around.

matto1990
Woops, looks like Sephy got to it first
matto1990