I'm trying to draw two views, one of which will overlay the other, using constraint layouts and, constraint_guidelines, and app:layout_constraintDimensionRatio="h, 1:1"
for their sizing (this is because I'll be using custom views which need to know their own sizing when drawing)
I'm trying to constrain one layout's top and bottom to the other one's bottom to ensure they're positioned relative to one another, but it seems as soon as I use the match_parent for their sizing, the constraints don't allow them to overlay one another.
This is how I'd like them to lay out;
Note, above screenshot was taken with smaller imageView manually placed
This is how they layout with both the second images dimensions set to match_parent, and ratio set
If I had to guess, I'd say the issue is because I'm simultaneously trying to match height with a constraint which would lead to a height of 0dp, while also giving it a ratio that ensures its height matches the width between the guidelines.
Below is the XML. If anybody can tell me how to get a layout to constrain to one point while deriving height from the width between the guidelines, would be much appreciated
<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:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.constraintlayout.widget.Guideline
android:id="@+id/example_guideline_left_one"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintGuide_percent="0.3"
app:layout_constraintStart_toStartOf="parent" />
<androidx.constraintlayout.widget.Guideline
android:id="@+id/onboarding_role_guideline_right_one"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintGuide_percent="0.7"
app:layout_constraintStart_toStartOf="parent" />
<ImageView
android:id="@+id/example_image_one"
android:layout_width="0dp"
android:layout_height="0dp"
android:background="@color/colorPrimaryDark"
app:layout_constraintDimensionRatio="h, 1:1"
app:layout_constraintEnd_toStartOf="@+id/onboarding_role_guideline_right_one"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toStartOf="@+id/example_guideline_left_one"
app:layout_constraintTop_toTopOf="parent" />
<androidx.constraintlayout.widget.Guideline
android:id="@+id/example_guideline_left_two"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintGuide_percent="0.55"
app:layout_constraintStart_toStartOf="parent" />
<androidx.constraintlayout.widget.Guideline
android:id="@+id/onboarding_role_guideline_right_two"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintGuide_percent="0.85"
app:layout_constraintStart_toStartOf="parent" />
<ImageView
android:id="@+id/example_image_two"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintDimensionRatio="h, 1:1"
app:layout_constraintBottom_toBottomOf="@+id/example_image_one"
app:layout_constraintEnd_toStartOf="@+id/onboarding_role_guideline_right_two"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toStartOf="@+id/example_guideline_left_two"
app:layout_constraintTop_toBottomOf="@+id/example_image_one" />
app:layout_constraintGuide_percent
. I've updated the xml to reflect this, sorry for the confusion – Biggs