user924
user924

Reputation: 12135

What happened to constraint layout and its dimension ratio attribute in 2.0.2 version?

I have an ImageView setup like this

<ImageView
    android:layout_width="0dp"
    android:layout_height="@dimen/video_file_item_image_height"
    android:background="@color/black"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintDimensionRatio="16:9"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent" />

with

implementation 'androidx.constraintlayout:constraintlayout:2.0.1'

it looks like this

enter image description here

but with

implementation 'androidx.constraintlayout:constraintlayout:2.0.2'

ImageView is not visible

enter image description here

Update

Version 2.0.3 it's still not fixed, it only works if you don't set dp for height (e.g. you set wrap_content instead) and app:layout_constraintEnd_toEndOf= is also required, but it works then differently, I need to set height in DPI! It worked like this in 2.0.1 and app:layout_constraintEnd_toEndOf= wasn't required to be set

Upvotes: 4

Views: 540

Answers (1)

Ben P.
Ben P.

Reputation: 54194

It looks like this is a known issue: https://issuetracker.google.com/issues/170313444

The recommended workaround is to add this to your ConstraintLayout tag:

app:layout_optimizationLevel="cache_measures"

Upvotes: 3

Related Questions