在 ConstraintLayout 中使用 TextView 时遇到问题,*match constraint* 和 *wrap_content* 都没有给出理想的结果

问题描述

我有一个文本视图。我真的不明白为什么 wrap_content 不起作用,或者有时 match constraint 可以解决问题,而问题在于包装。在这种情况下,我无法让消息出现在我的屏幕上。我不介意它是单行还是下一行中的感叹号,我想掌握在这种情况下使用什么或出现的任何其他情况的性质。

<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

我见过类似的问题,似乎 app:layout_constrainedHeight="true"app:layout_constrainedWidth="true" 成功了,但我没有看到使用它们的任何区别。

“Level 1”在我的手机和模拟器上看起来是这样的。我想在没有修剪的情况下发布此文本,并通过使用匹配约束wrap_content来真正了解为什么它会被剪切。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)