Reputation: 21361
This might sound very stupid but I am struggling with this so bear with me for a sec.
So I have this simple TextView
that I want to have centered within the screen:
<TextView
android:id="@+id/helloTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:includeFontPadding="false"
android:text="Hello!"
android:textSize="50sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.464" />
I tried it with wrap_content
and with match_constraint
but I wasn't able to get it centered. When I do wrap_content
the box is centered correctly but the text within is not as you can see here:
and when I do match_constraint
it just centers it vertically but not horizontally:
What am I missing out on?
Upvotes: 0
Views: 35
Reputation:
In your TextView's xml as you posted it add:
android:textAlignment="center"
Upvotes: 2