TextView does not center on android 4.1.1 [duplicate]

1

I have a problem in my layout , in API 16 (4.1.1) the TextView is not centered. I'm using ConstraintLayout .

The properties in XML look like this:

 <TextView
        android:id="@+id/txv_textomeio"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginBottom="8dp"
        android:layout_marginLeft="8dp"
        android:layout_marginRight="8dp"
        android:layout_marginTop="8dp"
        android:fontFamily="sans-serif-condensed"
        android:text="@string/textoinicial"
        android:textAlignment="center"
        android:textAllCaps="false"
        android:textSize="24sp"
        android:textStyle="bold"
        app:layout_constraintBottom_toTopOf="@+id/btn_iniciar"
        app:layout_constraintHorizontal_bias="0.5"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/txv_certo"
        app:layout_constraintVertical_bias="0.503" />

    
asked by anonymous 26.08.2017 / 16:59

1 answer

1

Change the property layout_width to match_parent .

Instead of:

android:layout_width="wrap_content"
android:textAlignment="center"

Place:

android:layout_width="match_parent"
android:gravity="center"
    
26.08.2017 / 17:03