Android:gravity: Sets the content location above the control itself
Android:layout_gravity: Sets the display position of the control itself relative to the parent control.
Look at the following code snippet
<?XML version="1.0"encoding="Utf-8"?>
<!--Android:gravity Sets the display position of the text above the button, and android:layout_gravity sets the position where the button appears in the layout. -
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
Android:orientation="Vertical"
Android:layout_width="fill_parent"
Android:layout_height="fill_parent">
<Button android:layout_width="250dip"
Android:gravity=" Right"
Android:layout_height="wrap_content"
Android:text="I'm right on display ."
Android:layout_gravity=" Right"/>
</LinearLayout>
The result is that the text of the button appears on the right, and the button appears on the right side of the screen, running as follows