微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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

如何解决在 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 举报,一经查实,本站将立刻删除。