Having trouble with TextView in ConstraintLayout, neither *match constraint* nor *wrap_content* give desirable result

266 views Asked by At

I have a TextView. I really can't get why wrap_content doesn't work, or sometimes match constraint does the trick whereas the issue is about wrapping. In this case, I can't make the message appear in my screen. I don't mind if it's a singleline or the exclamation pops in the next one, I want to grasp the nature of what to use in this situation or any other that arises.

<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:layout_height="match_parent">

<TextView
    android:id="@+id/levelMathQuizTextVIew"
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    android:layout_marginStart="8dp"
    android:layout_marginTop="8dp"
    android:layout_marginEnd="8dp"
    android:layout_marginBottom="8dp"
    android:fontFamily="cursive"
    android:gravity="center"
    android:text="Level 1!"
    android:textAlignment="center"
    android:textColor="@color/black"
    android:textSize="100sp"
    android:textStyle="bold|italic"
    app:layout_constrainedHeight="true"
    app:layout_constrainedWidth="true"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>

horizontally clipped rendering

I've seen similar problems, it seems app:layout_constrainedHeight="true" or app:layout_constrainedWidth="true" did the trick, but I haven't seen any difference using them.

The "Level 1" looks like that on my mobile phone and on the emulator. I would like to post this text without it being trimmed and really get to know why it is clipped by using either match constraint or wrap_content.

0

There are 0 answers