我有一个文本视图。我真的不明白为什么wrap_content不起作用,或者有时匹配约束可以解决问题,而问题在于包装。在这种情况下,我无法让消息出现在我的屏幕上。我不介意它是单行还是下一行弹出感叹号,我想掌握在这种情况下使用什么或出现任何其他情况的性质。
<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>
我见过类似的问题,似乎app:layout_constrainedHeight="true"或app:layout_constrainedWidth="true"成功了,但我没有看到使用它们有什么不同。
“Level 1”在我的手机和模拟器上看起来像这样。我想在不修剪的情况下发布此文本,并真正了解为什么使用匹配约束或wrap_content来修剪它。