任何大小时,约束布局中的 TextView 显示错误

Wrong TextView display in constraintlayout when anysize

我不知道这是否是一个错误,但如果您尝试这种布局:

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

    <TextView
        android:text="Lorem ipsum dolor sit amet, duo aperiri eruditi cu, lorem assum pro eu. Eos ea nostrum detraxit, ne etiam iisque pro. Melius ceteros eu vel, per aliquip habemus at. Vix wisi utinam regione eu. At qui ipsum choro, et primis periculis eos. Putant aperiam mea ad, id mei prompta denique, velit voluptatibus sit ea. Discere accusam an quo."
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:id="@+id/textView"
        app:layout_constraintLeft_toLeftOf="@+id/activity_main"
        android:layout_marginStart="16dp"
        app:layout_constraintTop_toTopOf="@+id/activity_main"
        android:layout_marginTop="16dp"
        app:layout_constraintRight_toRightOf="@+id/activity_main"
        android:layout_marginEnd="16dp" />

</android.support.constraint.ConstraintLayout>

文本显示不正确。我认为预期的行为是这样的:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/activity_main"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.example.dani.constraint.MainActivity">

    <TextView
        android:id="@+id/textView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginEnd="16dp"
        android:layout_marginStart="16dp"
        android:layout_marginTop="16dp"
        android:text="Lorem ipsum dolor sit amet, duo aperiri eruditi cu, lorem assum pro eu. Eos ea nostrum detraxit, ne etiam iisque pro. Melius ceteros eu vel, per aliquip habemus at. Vix wisi utinam regione eu. At qui ipsum choro, et primis periculis eos. Putant aperiam mea ad, id mei prompta denique, velit voluptatibus sit ea. Discere accusam an quo." />

</RelativeLayout>

有没有办法在不为父级设置填充的情况下实现与相对布局相同的结果?我正在使用 com.android.support.constraint:constraint-layout:1.0.0-alpha4

这是一个错误,已在 alpha 5 中修复——您需要更新到更新版本的 ConstraintLayout(alpha 6 刚刚发布)

com.android.support.constraint:constraint-layout:1.0.0-alpha6