Reputation: 11752
I have such constraints that creates chain_style packed between to textviews and if textview has wrap_content defined it doesn't wrap if set to 0dp it occupies all available space so Archived label is always at the right side of the layout not just after first textview
<TextView
android:id="@+id/nameTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@{deal.name}"
tools:text="Deal Name Deal Name Deal Name Deal Name Deal Name Deal Name Deal Name"
style="@style/ItemDealTitleTextAppearance"
android:autoSizeTextType="none"
app:layout_constraintHorizontal_bias="0.0"
android:layout_marginStart="24dp"
android:layout_marginTop="4dp"
android:layout_marginBottom="4dp"
app:layout_constraintHorizontal_chainStyle="packed"
android:layout_marginEnd="100dp"
app:layout_constraintTop_toBottomOf="@id/amountTextView"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintBottom_toTopOf="@id/verticalFlow"
app:layout_constraintEnd_toStartOf="@id/archivedTextView"
/>
<TextView
android:id="@+id/archivedTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="@style/ArchiveLabelStyle"
android:paddingStart="4dp"
android:paddingEnd="4dp"
app:visibleGone="@{deal.isArchived == true}"
android:text="Archived"
android:layout_marginEnd="24dp"
android:layout_marginStart="16dp"
app:layout_constraintStart_toEndOf="@id/nameTextView"
app:layout_constraintTop_toTopOf="@id/nameTextView" />
Upvotes: 0
Views: 1681
Reputation: 6316
Right now, there is no chain as the TextView on the right has no end constraint. Add app:layout_constraintEnd_toEndOf="parent"
constraint to the archivedTextView
to create a valid horizontal chain.
Add app:layout_constrainedWidth="true"
to the nameTextView
and keep its width as android:layout_width="wrap_content"
.
This will keep the long text within the constraints and cause it to wrap.
Upvotes: 10