Android Studio: не помещается RecyclerView в NestedScrollView
Не помещаются все элементы RecyclerView в NestedScrollView. Привожу картинку в качестве примера.
Элементы RecyclerView #2 просто не влезают по высоте в NestedScrollView. Не могу понять - почему. Код разметки у меня сейчас выглядит следующим образом:
<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=".MainActivity">
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/header_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent">
<View
android:id="@+id/some_view"
android:layout_width="match_parent"
android:layout_height="120dp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
android:layout_marginTop="5dp" />
</androidx.constraintlayout.widget.ConstraintLayout>
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fillViewport="true"
app:layout_constraintTop_toBottomOf="@id/header_layout"
android:layout_marginTop="10dp">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/firstHeader"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="HEADER #1"
android:textSize = "20sp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:layout_marginTop="20dp" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/firstRecyclerView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:listitem="@layout/list_item"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
android:orientation="vertical"
app:layout_constraintTop_toBottomOf="@+id/firstHeader"
android:layout_marginTop="10dp"/>
<TextView
android:id="@+id/secondHeader"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="HEADER #2"
android:textSize = "20sp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:layout_marginTop="20dp" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/secondRecyclerView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:listitem="@layout/list_item"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
android:orientation="vertical"
app:layout_constraintTop_toBottomOf="@+id/secondHeader"
android:layout_marginTop="10dp"/>
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.core.widget.NestedScrollView>
</androidx.constraintlayout.widget.ConstraintLayout>
