我将 RecyclerView 与 PagedListAdpter 一起使用 如果我将 recyclerView 的高度和宽度设置为MATCH_PARENT
,则adapter.submitList(someList)
工作正常,但如果我将高度和宽度设置为0dp(for constraintLayout)
它不起作用,则不会调用适配器和 ViewHolder 中的方法。
约束布局里面有什么错误吗?
XML代码如下:
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/search_result_root"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:id="@+id/search_input_layout"
android:layout_width="match_parent"
android:layout_height="60dp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent">
<androidx.appcompat.widget.AppCompatEditText
android:id="@+id/search_input"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<Button
android:id="@+id/search_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:text="tasdf"
app:layout_constraintBottom_toBottomOf="@id/search_input"
app:layout_constraintRight_toRightOf="@id/search_input"
app:layout_constraintTop_toTopOf="@id/search_input" />
</RelativeLayout>
<Spinner
android:id="@+id/search_options"
android:layout_width="60dp"
android:layout_height="30dp"
android:background="@color/color_transparent"
android:spinnerMode="dropdown"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="@id/search_input_layout" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/search_recyclerview"
android:layout_width="0dp"
android:layout_height="0dp"
android:clipToPadding="false"
android:paddingLeft="10dp"
android:paddingTop="20dp"
android:paddingRight="10dp"
android:paddingBottom="20dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@id/search_options" />
</androidx.constraintlayout.widget.ConstraintLayout>
</layout>