1.由于线性布局LinearLayout 包裹的RecyclerView 使用了android:layout_weight="1" 属性 这时候notifyDataSetChanged onBindViewHolder失效 ,RecyclerView外再包FrameLayout android:layout_weight="1" 属性 用在FrameLayout上
<?xml version="1.0" encoding="utf-8"?> <LinearLayout 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="match_parent" android:background="@color/white" android:orientation="vertical"> <com.xag.factory.operation.v4v2.wigdet.view.TopBarView android:id="@+id/top_bar" android:layout_width="match_parent" android:layout_height="wrap_content" app:layout_constraintTop_toTopOf="parent" app:topbar_bg="@color/white" app:topbar_title_text="一键检测" /> <View android:layout_width="match_parent" android:layout_height="0.5dp" android:background="@color/basecompat_divider" /> <FrameLayout android:layout_width="match_parent" android:layout_height="0dp" android:layout_marginTop="@dimen/dp_10" android:layout_weight="1"> <androidx.recyclerview.widget.RecyclerView android:id="@+id/rv_view" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_marginStart="@dimen/dp_12" android:layout_marginEnd="@dimen/dp_12" android:background="@drawable/operation_shape_white_round_outline" android:minHeight="168dp" android:padding="@dimen/dp_12" /> </FrameLayout> <TextView android:id="@+id/btn_start_detection" android:layout_width="match_parent" android:layout_height="@dimen/dp_46" android:layout_marginStart="@dimen/dp_12" android:layout_marginTop="@dimen/dp_10" android:layout_marginEnd="@dimen/dp_12" android:layout_marginBottom="@dimen/dp_12" android:background="@drawable/button_border_press_8dp" android:gravity="center" android:text="开始一键检测" android:textColor="@color/basecompat_green" /> </LinearLayout>