我在RecyclerView内部有一个ViewHolder的XML布局。ConstraintLayout beta5 wrap_content未正确包装
此布局的根部是一个ConstraintLayout,其高度设置为wrap_content
。
在这个平面层次结构中,有3个textview和一个固定高度的图像视图;认为:
<ConstraintLayout>
<TextView height=wrap>
<TextView height=wrap>
<TextView height=wrap>
<ImageView height=150dp>
</ConstraintLayout>
这是一个相对简单的布局。在beta4
这是它的外观在设计(并最终在运行时,每个recyclerView细胞):
道歉的“繁文缛节”,但它的保密协议等等等等。
如此说来,所述元素是:
3个文本视图(红色胶粘用一个漂亮的紫色背景) 与150dp高度的ImageView的是灰色的事情。
紫色背景已应用于根ConstraintLayout。一切都很好。
现在,这是它的外观,没有一个单一的修改与测试版5:
正如你可以看到紫色(根)约束布局现在“糊涂”,不包内容像以前一样。
事情我想:
添加
app:layout_constraintHeight_default="wrap"
到ConstraintLayout(和传播太)。没有区别。该ImageView有一个
app:layout_constraintBottom_toBottomOf="parent"
约束,我试图删除,也没有任何区别。恢复到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!):)