ConstraintLayout 1.1.0 is different from 1.0.2, is this a bug?

If I use 1.0.2, the width of 3 images is average, and their height is calculated using the radio station that I installed. If I use 1.1.0, their height is equal 0dp, and I can’t see anything unless set android:layout_height="match_parent"
in the root ConstraintLayout.

This is mistake? Here is my code:

<android.support.constraint.ConstraintLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <ImageView
        android:id="@+id/iv0"
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:background="#FF0000"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toLeftOf="@+id/iv1"
        app:layout_constraintDimensionRatio="2:1"/>

    <ImageView
        android:id="@+id/iv1"
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:background="#00FF00"
        app:layout_constraintDimensionRatio="2:1"
        app:layout_constraintLeft_toRightOf="@id/iv0"
        app:layout_constraintRight_toLeftOf="@+id/iv2"/>

    <ImageView
        android:id="@+id/iv2"
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:background="#0000FF"
        app:layout_constraintDimensionRatio="2:1"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintLeft_toRightOf="@id/iv1"/>

</android.support.constraint.ConstraintLayout>
+4
source share
1 answer

According to the updated document , the layout behavior has changed in ConstraintLayout 1.1.0 :

WRAP_CONTENT: ( 1.1)
​​ WRAP_CONTENT, 1.1 - , . ( ), WRAP_CONTENT, . :

  • app:layout_constrainedWidth="true|false"
  • app:layout_constrainedHeight="true|false"

, XML :

android:layout_height="0dp"

android:layout_height="0dp"
app:layout_constrainedHeight="true"

.

+1

Source: https://habr.com/ru/post/1696296/


All Articles