Center Align Android TextView Text


Center Align Text in TextView Android

To center align the Text in a TextView we can name use of the property android:textAlignment="center", let us see an example where we have a with layout width as fill_parent and height as wrap_content and the text is center aligned.


<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <TextView
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="Hello World"
        android:textAlignment="center"
        android:id="@+id/myTextView"/>
</LinearLayout>


-


Have Questions? Post them here!

Top Hashtags:

Advertisements

Advertisements




Advertisements