constraint layout left and right constraint
Try this, the width is 0dp
and using app:layout_constraintHorizontal_weight
you can adjust the width as per your requirement.
<ImageView
android:id="@+id/iconIv"
android:layout_width="36dp"
android:layout_height="36dp"
android:src="@mipmap/ic_launcher_round"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toStartOf="@+id/nameTv"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/nameTv"
android:layout_width="0dp"
app:layout_constraintHorizontal_weight="2"
android:layout_height="wrap_content"
android:text="Some text"
app:layout_constraintStart_toEndOf="@+id/iconIv"
app:layout_constraintEnd_toStartOf="@+id/priceFl"
app:layout_constraintTop_toTopOf="parent" />
<FrameLayout
android:id="@+id/priceFl"
android:layout_width="0dp"
app:layout_constraintHorizontal_weight="1"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/nameTv"
app:layout_constraintTop_toTopOf="parent">
</FrameLayout>
I prefer using constraintStart
and constraintEnd
instead of constraintLeft
and constraintRight
, just a personal choice.
Try this
<TextView
android:id="@+id/nameTv"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintLeft_toRightOf="@id/iconIv"
app:layout_constraintRight_toLeftOf="@+id/priceFl"
app:layout_constraintTop_toTopOf="parent"/>