Android Basics – Using gravity and layout_gravity attributes to align View Elements

If you are using Linear Layout you have two attributes available to help you align the UI elements.

Gravity Attribute

Use gravity attribute to align the View Content – center, left, right etc.

Layout Gravity Attribute

Use layout_gravity to align the View element itself.

In the following Video I show you how to use these attributes

Source Code : https://github.com/ankur-srivastava/HelloAndroid/blob/master/app/src/main/res/layout/activity_main.xml