ConstraintLayout beta5 wrap_content does not complete

I have an XML layout for a ViewHolder inside a RecyclerView.

This layout root is a ConstraintLayout whose height is set to wrap_content.

Inside this flat hierarchy there are 3 text images and a fixed-height image; think:

<ConstraintLayout>
     <TextView height=wrap>
     <TextView height=wrap>
     <TextView height=wrap>
     <ImageView height=150dp>
</ConstraintLayout>

This is a relatively simple layout. It beta4looks like this in the constructor (and, ultimately, at runtime, each recyclerView cell):

Beta4

Apologies for the "red tape", but this is the NDA blah blah.

In this case, the elements:

3 text views (red ribbon with a beautiful purple background) ImageView with a height of 150dp is a gray thing.

A purple background has been applied to the root of ConstraintLayout. Things are good.

Now here's what it looks like, without a single modification with Beta 5:

beta5

, () Constraint Layout "" , .

, :

  • app:layout_constraintHeight_default="wrap" ConstraintLayout ( ). .

  • ImageView app:layout_constraintBottom_toBottomOf="parent", , .

  • 4:)

( : ). .

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.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="wrap_content"
    android:background="@color/colorAccent">

    <TextView
        android:id="@+id/toplabel"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginStart="8dp"
        android:layout_marginTop="8dp"
        android:text=""
        android:textStyle="bold"
        app:layout_constraintBottom_toBottomOf="@+id/top_bottom_label"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toLeftOf="@+id/top_right_label"
        app:layout_constraintTop_toTopOf="parent" />

    <TextView
        android:id="@+id/top_right_label"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginEnd="8dp"
        android:layout_marginTop="8dp"
        android:ellipsize="end"
        android:gravity="end"
        android:maxLines="1"
        android:text=""
        app:layout_constraintBottom_toTopOf="@+id/top_bottom_label"
        app:layout_constraintHorizontal_bias="1.0"
        app:layout_constraintLeft_toRightOf="@+id/toplabel"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintVertical_chainStyle="packed" />

    <TextView
        android:id="@+id/top_bottom_label"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginEnd="8dp"
        android:layout_marginTop="8dp"
        android:ellipsize="end"
        android:gravity="end"
        android:maxLines="1"
        android:text=""
        app:layout_constraintHorizontal_bias="1.0"
        app:layout_constraintLeft_toRightOf="@+id/toplabel"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/top_right_label" />

    <ImageView
        android:id="@+id/imageview"
        android:layout_width="0dp"
        android:layout_height="150dp"
        android:layout_marginTop="8dp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/top_bottom_label"
        app:srcCompat="@android:color/darker_gray" />

</android.support.constraint.ConstraintLayout>

- ? ( , RelativeLayout , , , ... ConstraintLayout!):)

+4
1

I , .

​​( ), ... , . top_bottom_label .

, app:layout_constraintBottom_toTopOf="@id/imageview" top_bottom_label, , , . , . .

14 2017 . ConstraintLayout @Google . , . (!).

+5

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


All Articles