简体   繁体   English

layout_constraintHeight_default="wrap" 没有正确包装 TextView

[英]layout_constraintHeight_default="wrap" not correctly wrapping TextView

I was having trouble getting some views to wrap to the correct height while matching constraints, and I managed to condense my issue down to a single text view.在匹配约束时,我无法让一些视图环绕到正确的高度,我设法将我的问题浓缩为单个文本视图。

For some reason, when I'm using layout_constrainedWidth and layout_constrainedHeight, they can't handle text views that just barely wrap onto the next line.出于某种原因,当我使用 layout_constrainedWidth 和 layout_constrainedHeight 时,它们无法处理几乎没有换行到下一行的文本视图。

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/coordinator_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

        <TextView
            android:id="@+id/textView"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginStart="32dp"
            android:layout_marginTop="8dp"
            android:layout_marginEnd="64dp"
            android:layout_marginBottom="8dp"
            android:text="If a single word wraps onto the next line it is cut off one"
            android:visibility="visible"
            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" />

</android.support.constraint.ConstraintLayout>

I'm actually using it on a scroll view that contains some text views, and it doesn't work at all unless I also apply it to the child views as well.我实际上是在包含一些文本视图的滚动视图上使用它,除非我也将它应用于子视图,否则它根本不起作用。

Is this a bug in Android?这是Android中的错误吗?

Yes, it was a bug in Android.是的,这是Android中的一个错误。

https://issuetracker.google.com/issues/123551995 https://issuetracker.google.com/issues/123551995

Google marked it as resolved with the release of ConstraintLayout 2.0 beta 2随着 ConstraintLayout 2.0 beta 2 的发布,Google 将其标记为已解决

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM