我有一个StaggeredLayout RecyclerView充满了不同卡的使用CardView,在这些卡内通常有一个ConstraintLayout所有字段都是空的.一切都有wrap_content高度.
我的问题是,似乎在填充任何数据之前计算了CardView高度,之后没有更新.我已经尝试过直接无效,设置measureAllChildren为true,使用requestLayout上itemView与制作,使得底部的项目有一个约束到父的底部,但问题持之以恒.
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/home_card_half_min_gutter">
<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:layout_gravity="center"
android:padding="@dimen/content_spacing">
<ImageView
android:id="@+id/iv_icon"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginBottom="@dimen/content_spacing"
android:contentDescription="@string/icon"
app:layout_constraintBottom_toTopOf="@+id/guideline"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/ic_airplanemode_inactive_accent_dark_24dp"
android:scaleType="fitCenter"/>
<android.support.constraint.Guideline
android:id="@+id/guideline"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintGuide_percent="0.35" />
<TextView
android:id="@+id/tv_item_1_label"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="0dp"
android:textAppearance="@style/TextAppearance.AppCompat.Caption"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toLeftOf="@+id/guideline5"
app:layout_constraintTop_toTopOf="@+id/guideline"
tools:text="TextView" />
<TextView
android:id="@+id/tv_item_1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/content_half_spacing"
android:textAppearance="@style/Base.TextAppearance.AppCompat.Body1"
app:layout_constraintLeft_toLeftOf="@+id/tv_item_1_label"
app:layout_constraintRight_toLeftOf="@+id/guideline5"
app:layout_constraintTop_toBottomOf="@+id/tv_item_1_label"
tools:text="TextView" />
<TextView
android:id="@+id/tv_item_2_label"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:textAppearance="@style/TextAppearance.AppCompat.Caption" …Run Code Online (Sandbox Code Playgroud) android android-view android-recyclerview android-constraintlayout