Gravity and layout gravity on Android

De openkb
Aller à : Navigation, rechercher

Sommaire

Questions

I know we can set the following values to the android:gravity and android:layout_gravity properties:

    • center
    • center_vertical
    • center_horizontal, etc.

But I am confused regarding both of these.

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

Answers

Their names 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.

http://thinkandroid.wordpress.com/2010/01/14/how-to-position-views-properly-in-layouts/ http://thinkandroid.wordpress.com/2010/01/14/how-to-position-views-properly-in-layouts/

Source

License : cc by-sa 3.0

http://stackoverflow.com/questions/3482742/gravity-and-layout-gravity-on-android

Related

Outils personnels
Espaces de noms

Variantes
Actions
Navigation
Outils