I am using ConstraintLayout to do an android app page.
Here is my code:
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/main"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".test2">
<ImageView
android:id="@+id/left_image"
android:layout_width="40dp"
android:layout_height="40dp"
app:srcCompat="@drawable/ic_launcher_background"/>
<ImageView
android:id="@+id/right_image"
android:layout_width="110dp"
android:layout_height="110dp"
android:layout_marginTop="9dp"
android:layout_marginEnd="9dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/ic_launcher_background"/>
<TextView
android:id="@+id/text_view"
android:layout_width="wrap_content"
android:layout_height="40dp"
android:text="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
app:layout_constraintStart_toEndOf="@id/left_image"
app:layout_constraintEnd_toStartOf="@id/right_image" />
</androidx.constraintlayout.widget.ConstraintLayout>
I got this result:
But I want the text be constrainted by the left image’s right boundary, and right image’s left boundary. How to solve this unexpected result?