I am trying to create a TextView such that it wraps its content until it reaches its max width. Following code kind of achieves that perfectly until it is used in RecyclerView. It seems like TextView doesn't measure its width again after I change its text in onBindViewHolder().
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/message"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintWidth_max="wrap"
app:layout_constraintWidth_default="percent"
app:layout_constraintWidth_percent="0.72" />
</androidx.constraintlayout.widget.ConstraintLayout>
However notice how it works fine if I invoke requestLayout() on TextView in onBindViewHolder() below:
Update: Following code in onBindViewHolder() works too.
ConstraintSet().apply {
clone(holder.parent)
applyTo(holder.parent)
}
parent being ConstraintLayout.
Does anyone understand whats going on here? Is this a bug in ConstraintLayout? Invoking requestLayout() in onBindViewHolder() is a bad practice and I don't want to do that.

