differences between gravity and layout_gravity in android

android:layout_gravity is the Outside gravity of the View. That means, to specify the direction in which the View should touch it’s parent’s border.

android:gravity is the Inside gravity of that View. This means, in which direction it’s contents should align.

HTML/CSS Equivalents:

android:layout_gravity = float in CSS

android:gravity = text-align in CSS

Easy trick to remember: Take “layout-gravity” as “Lay-outside-gravity”


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s