ConstraintLayout在textview中切断文本

Est*_*ban 9 xml android android-constraintlayout

我有一ConstraintLayout对夫妇的意见,由于某种原因,我textview在句子结束时被切断了.它textview被限制在左侧和顶部.是的tv_product_description textview.

<android.support.constraint.ConstraintLayout
    android:id="@+id/ll_product_holder"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginLeft="16dp"
    android:layout_marginRight="16dp"
    android:layout_marginTop="16dp"
    android:background="@drawable/drawable_border"
    android:orientation="vertical">

    <com.facebook.drawee.view.SimpleDraweeView
        android:id="@+id/iv_product_image"
        android:layout_width="100dp"
        android:layout_height="100dp"
        android:layout_marginBottom="8dp"
        android:layout_marginLeft="9dp"
        android:layout_marginStart="9dp"
        android:layout_marginTop="13dp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/price_holder"
        fresco:actualImageScaleType="centerCrop"
        fresco:placeholderImage="@drawable/placeholder2"/>

    <TextView
        android:id="@+id/tv_product_id"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginLeft="9dp"
        android:layout_marginStart="9dp"
        android:layout_marginTop="13dp"
        android:text="@{historyItem.productId}"
        app:layout_constraintLeft_toRightOf="@+id/iv_product_image"
        app:layout_constraintTop_toBottomOf="@+id/price_holder"/>

    <TextView
        android:id="@+id/tv_product_description"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginLeft="9dp"
        android:layout_marginStart="9dp"
        android:ellipsize="end"
        android:maxLines="2"
        android:text="@{historyItem.productDescription}"
        app:layout_constraintLeft_toRightOf="@+id/iv_product_image"
        app:layout_constraintTop_toBottomOf="@+id/tv_product_id"/>

</android.support.constraint.ConstraintLayout>
Run Code Online (Sandbox Code Playgroud)

在这里你可以看到textview被切断了.

Dha*_*ngh 23

请添加正确的约束

app:layout_constraintRight_toRightOf="parent"
Run Code Online (Sandbox Code Playgroud)

请设置宽度0dp之类的

android:layout_width="0dp"
Run Code Online (Sandbox Code Playgroud)

产量

在此输入图像描述

  • 这是`android:layout_width ="0dp"`,谢谢! (3认同)

Nix*_*gei 5

对我来说,这通过以下内容起作用

app:layout_constraintEnd_toEndOf="parent"
Run Code Online (Sandbox Code Playgroud)

宽度为

android:layout_width="0dp"
Run Code Online (Sandbox Code Playgroud)