RecyclerView高度使用wrap_content时最后一行显示不全,需在RecyclerView包裹一层布局,并确定外层布局的高度;或者分配剩余空间;如果父布局使用ConstraintLayout,则确定顶部和底部定位,并且高度设为0dp。如果外层嵌套ScrollView,改成NestedScrollView。
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.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="match_parent"
tools:context=".me.activity.MyXuedouActivity">
<include
android:id="@+id/xuedou_top"
layout="@layout/activity_top"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/list_mingxi"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginStart="@dimen/common_10dp"
android:layout_marginEnd="@dimen/common_10dp"
android:layout_marginTop="@dimen/common_12dp"
android:background="@drawable/background_bg_white_course"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/xuedou_top" />
</androidx.constraintlayout.widget.ConstraintLayout>