在 ConstraintLayout 中查看内容越界

View content gets out off bounds in ConstraintLayout

我需要将两个 TextViews 排成一行并与动态内容和宽度对齐。 ConstraintLayout 在文本开始换行之前效果很好。左视图在第二个视图的宽度上向左移动(超出左边界)。如何避免这种情况?是某种错误还是我忘记了错误地使用 ConstraintLayout

<?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:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_margin="16dp">

    <TextView
        android:id="@+id/textView2"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:text="textView2 Lorem ipsum "
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_chainStyle="packed"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintWidth_default="wrap" />


    <TextView
        android:id="@+id/textView1"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:background="@color/colorAccent"
        android:text="textView1 Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua."
        app:layout_constraintEnd_toStartOf="@+id/textView2"
        app:layout_constraintHorizontal_chainStyle="packed"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="@+id/textView2"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintWidth_default="wrap" />

</android.support.constraint.ConstraintLayout>

移位视图图像:

layout_constraintLeft_toLeftOf 更改为 layout_constraintStart_toStartOf,将 layout_constraintRight_toRightOf 更改为 layout_constraintEnd_toEndOf,您将得到如下所示的内容:

这假定 ConstraintLayout 版本 1.1.0,尽管它可能无关紧要。

您可以将它与从第一个文本视图末尾开始的指南联系起来。两种文本视图都可以有与指南相关的结束。

 <androidx.constraintlayout.widget.Guideline
    android:id="@+id/glMiddle"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    app:layout_constraintGuide_begin="56dp" />

将 tv1 的结尾与此联系起来并将 tv2 的开始与此联系起来