In xml layout, gravity of the TextView is setted. In some condition, I want to change the gravity of the TextView in my coding.I have tried to set like this:
title.setGravity(Gravity.START);
but no change.
In xml I have aligned text view gravity to center. I have to change this gravity to START in some condition programmatically:
<TextView
android:id="@+id/text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginEnd="8dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:gravity="center"
android:text=" "
android:drawablePadding="5dp"
android:textColor="@color/colorPrimary"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
So how to do that?