Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ConstraintLayout cuts off text in textview

I have a ConstraintLayout with couple views in it and for some reason my textview gets cut off towards the end of the sentence. The textview is constrained to the left and top. It is 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>

Here you can see the textview being cut off.

like image 553
Esteban Avatar asked May 02 '17 12:05

Esteban


1 Answers

Please add right constraint as well like

app:layout_constraintRight_toRightOf="parent"

and please set width 0dp like

android:layout_width="0dp"

Output

enter image description here

like image 189
Dharmbir Singh Avatar answered Sep 22 '22 08:09

Dharmbir Singh