0

I'm working on a simple android application , and i need to align some of views in a specific location but without using padding or constants integer values for sizes , I wanna do that using gravity attribute , Can any one tell me what is the gravity attribute and what is the difference between android:gravity and android:layout_gravity attribute .

and thanks in advance .

Mahmoud
  • 2,683
  • 1
  • 30
  • 32
  • http://thinkandroid.wordpress.com/2010/01/14/how-to-position-views-properly-in-layouts/ – Nermeen Apr 10 '13 at 07:41
  • Actually you should use the search function. Had you done so, you would end up with the answers http://stackoverflow.com/a/3482757/312312 – Lefteris Apr 10 '13 at 07:42

3 Answers3

4

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.

check https://stackoverflow.com/a/6819801/1434631

Community
  • 1
  • 1
Nermeen
  • 15,883
  • 5
  • 59
  • 72
1
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.
Nirav Ranpara
  • 13,753
  • 3
  • 39
  • 54
0

Gravity: will specify to where the content of the view will be alighted, meaning If you have a TextView and it's parameters are not wrap_content for both dimensions then Gravity will determine which boarder this text will touch.

Layout_Gravitiy: this will specify the location of the View inside it's parent layout, meaning that if you Layout is bigger the the View inside this will determine which boarder of this layout this View will touch.

Emil Adz
  • 40,709
  • 36
  • 140
  • 187