item布局是这样
<android.support.constraint.ConstraintLayout
android:id="@+id/root"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="8dp"
android:paddingRight="30dp"
android:paddingLeft="@dimen/dimen_dialog_connect_padding_left"
android:paddingBottom="8dp">
<TextView
android:id="@+id/tv_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@android:color/transparent"
android:singleLine="true"
android:textColor="@color/textColorBlack"
android:textSize="@dimen/dimen_main_message_small_size"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/tv_retry"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/retry"
android:textColor="@color/textColorBlack"
android:textSize="@dimen/dimen_main_message_small_size"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<ProgressBar
android:id="@+id/progressBarNormal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/tv_fail"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="21dp"
android:text="@string/connect_fail"
android:textColor="@color/textColorError"
android:textSize="@dimen/dimen_main_message_small_size"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintRight_toLeftOf="@id/tv_retry"
app:layout_constraintTop_toTopOf="parent" />
</android.support.constraint.ConstraintLayout>
</layout>
布局里面的RecvcleView是这样
<android.support.v7.widget.RecyclerView
android:id="@+id/rv_new"
android:layout_width="match_parent"
android:layout_height="72dp"
android:layout_marginTop="@dimen/dimen_dialog_connect_margin_top"
android:background="#00ff00"
android:maxHeight="72dp"
/>
这里如果layout_height设置为固定高度72,会出现item不能match_parent
但如果改成wrap_conteng,就不会有这个问题,但如果我一定要设置这个RecycleView的高度呢?
改成这样
<LinearLayout
android:layout_width="match_parent"
android:layout_height="72dp">
<android.support.v7.widget.RecyclerView
android:id="@+id/rv_new"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dimen_dialog_connect_margin_top"
android:background="#00ff00"
android:maxHeight="72dp"
/>
</LinearLayout>