constraintlayout icon indicating copy to clipboard operation
constraintlayout copied to clipboard

Optimizer bug with ratio and _default = wrap

Open oscar-ad opened this issue 3 years ago • 0 comments

Example:

<?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:layout_width="match_parent"
    android:layout_height="match_parent">

    <TextView
        android:id="@+id/textView"
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:text="TextView"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintDimensionRatio="1:2"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintWidth_default="wrap" />

</androidx.constraintlayout.widget.ConstraintLayout>

The TextView is measured to obtain it's wrap_content measurements, but then the optimizer does not consider match_constraint, so the height is not calculated with the ratio and the width does not consider it's remaining space in constraints.

oscar-ad avatar Dec 14 '21 01:12 oscar-ad