Effect: text on the left, icon on the right
When text is short, an icon relies only on text
When the text is long, the text wraps and the icon is on the right
<TextView
android:id="@+id/chargingTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="24dp"
android:layout_marginTop="10dp"
app:layout_constrainedWidth="true"
app:layout_constraintHorizontal_bias="0"
app:layout_constraintHorizontal_chainStyle="packed"
app:layout_constraintEnd_toStartOf="@+id/chargingPrepareIcon"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/toolbar_layout"
/>
<ImageView
android:id="@+id/chargingPrepareIcon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/base_icon_warning"
android:layout_marginStart="8dp"
android:layout_marginEnd="24dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/chargingTitle"
app:layout_constraintTop_toTopOf="@+id/chargingTitle"
app:layout_constraintBottom_toBottomOf="@+id/chargingTitle"
/>
If the text is too long in the ConstraintLayout, the TextView will exceed the constraint.