Вы должны попробовать использовать guidelines
.Таким образом, вы можете установить свою фотографию в любом месте вдоль стороны либо x or y-axis
.
<androidx.constraintlayout.widget.Guideline
android:id="@+id/guideline"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintGuide_percent="0.70" />
// app:layout_constraintGuide_percent="0.70"
here you can give the percentage, begining
`or ending of guideline and then add constraint.`
Так что в вашем случае ваш код будет выглядеть примерно так:
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto">
<ImageView
android:id="@+id/singapore"
android:scaleType="centerCrop"
android:layout_width="240dp"
android:layout_height="240dp"
android:src="@drawable/singapore"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
</ImageView>
<ImageView
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_marginTop="16dp"
android:src="@drawable/poster"
app:layout_constraintEnd_toEndOf="@id/singapore"
app:layout_constraintStart_toStartOf="@+id/singapore"
app:layout_constraintTop_toTopOf="@+id/guideline21">
</ImageView>
<androidx.constraintlayout.widget.Guideline
android:id="@+id/guideline21"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintGuide_percent="0.25" />
</androidx.constraintlayout.widget.ConstraintLayout>