Example for Android textview alignment –
To align a textview we need to use the ‘gravity’ property
<TextView android:text="@+id/TextView01" android:id="@+id/TextView01" android:layout_height="wrap_content" android:layout_width="fill_parent" android:gravity="center" />
Now we set the alignment to center so that textview text will appear in the center of the textview(see the below image).
We can set the gravity as top, right, left, bottom,etc…you can also set more than one gravity at a time.
For instance,
android:gravity=”right|center”
(Note: The red color lines won’t appear in the output.)