TextView will not center its content

Tom Macdonald
<TextView
        android:layout_height="30dp"
        android:text="@string/list_title"
        android:layout_gravity="center"
        android:layout_width="fill_parent"
        android:textSize="@dimen/title_size"
        android:textAlignment="center"
        android:layout_alignParentTop="true"
        android:background="@color/white"
        android:id="@+id/list_title"
        />

Is the first element in a RelativeLayout :

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:gravity="center">

But the text in the TextView will not center. I cannot understand why as all gravities and the textAlignment property are set to "center".

What am I doing wrong?

Manishika

Add android:gravity="center" to your textView

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

TextView will not center its content

From Dev

Center three columns and center its content

From Dev

Center content of TextView vertically & horizontally - LinearLayout

From Dev

ListItem lost its content after applying alignItems: 'center' to the parent view

From Dev

Android textview center positioning

From Dev

Center a button and textView

From Dev

Android textview center letter

From Dev

Android - Center Textview in LinearLayout

From Dev

Center a TextView in a TableRow in a TableLayout

From Dev

Align TextView to center of RelativeLayout

From Dev

Center a TextView in a TableRow in a TableLayout

From Dev

Unable to center the text in textview

From Dev

Dynamically create textview in center

From Dev

TextView Center Gravity not working

From Dev

Center child to the center of its parent

From Dev

Center RelativeLayout or its contents

From Dev

Image left to TextView, Textview should be in center

From Dev

Can't center textview in tablelayout

From Dev

Android: Vertically Center TextView in LinearLayout

From Dev

textview not align center below of imageview

From Dev

Align a textview to the center of progressbar in Android

From Dev

a textView refuses to center as a son of LinearLayout

From Dev

Layout: TextView at the top and ListView at the center

From Dev

Center ImageView and TextView Side by side

From Dev

Center align TextView in android layout

From Dev

android gravity center not working in textview

From Dev

Textview in center below of imageview Android

From Dev

Echo the content of a TextView?

From Dev

Echo the content of a TextView?