4

저는 RecyclerView 내부의 ViewHolder에 대한 XML 레이아웃을 가지고 있습니다.ConstraintLayout beta5 wrap_content가 제대로 랩되지 않습니다.

이 레이아웃의 루트는 높이가 wrap_content으로 설정된 ConstraintLayout입니다.

이 평면 계층에는 3 개의 텍스트 뷰와 고정 된 높이의 이미지 뷰가 있습니다. 생각해 :

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

비교적 간단한 레이아웃입니다. 은 "빨간 테이프"에 대한

Beta4

죄송하지만 NDA ㅋ ㅋ ㅋ ㅋ이다 : beta4이는 (결국 실행시, 각 recyclerView 세포) 디자이너의 모습입니다.

말했다되고 있다는 요소는 다음과 같습니다

3 텍스트 뷰 (빨간색이 좋은 보라색 배경에 테이프) 150dp 높이가 이미지 뷰는 회색 것입니다.

보라색 배경이 루트 ConstraintLayout에 적용되었습니다. 좋아.

지금이는 베타 5와 하나의 수정없이 모습입니다 :

beta5

당신은 퍼플 (루트) 제약 레이아웃은 지금 "혼란"하고 내용을 포장하지 않습니다 볼 수 있듯이 이전처럼.

것들 내가 시도 :

  1. 는 ConstraintLayout에 app:layout_constraintHeight_default="wrap" 추가 (너무 확산). 차이를 만들지 않았다.

  2. ImageView에 제거하려고 시도한제약이 있습니다. 차이를 만들지도 않았습니다.

  3. 되돌리기 다시 beta4에 :)

공식적으로,이 전체 레이아웃은 (의 빨간색 테이프 이유로 이름이 변경되었습니다 ID와 도구를 사용하지 않고 : 때문에 같은 이유에 텍스트 또는 이와 유사한 것) . 그렇지 않으면 레이아웃은 완전히 동일합니다.

<?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에서 믿을 !) :

답변

5

이것에 대해 filed a bug 내가 해결을 얻었다.

회귀이며 수정 될 예정이지만 (내 희망) 내 체인이 잘못 정의되었습니다. 내 top_bottom_label에는 하단 끝점 인이 없으며 체인의 문서 요소에 따라 은 양쪽 끝점에 연결되어야합니다.

top_bottom_labelapp:layout_constraintBottom_toTopOf="@id/imageview"을 추가했는데이 경우에 효과가있는 것 같습니다. 사실, 체인에 imageView를 추가했는데, 그다지 신경 쓰지 않아도됩니다. 그것은 현재 작동합니다.

업데이트 2 월 14 일 2017 : ConstraintLayout 팀 @ Google이 master에서 이슈를 수정했습니다. 그것은 다음 릴리스에서 수정 될 가능성이 있습니다. (감사!).