Сделайте так, чтобы ваш макет выглядел примерно так:
<android.support.constraint.ConstraintLayout
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">
<LinearLayout
android:width="match_parent"
android:height="wrap_content"
android:id="@+id/top_elements_holder"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toTopOf="@id/recyclerview">
<!-- Anything above the RecyclerView goes here -->
</LinearLayout>
<RecyclerView
android:width="match_parent"
android:height="0dp"
android:id="@+id/recyclerview"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/top_elements_holder"
app:layout_constraintBottom_toTopOf="@id/bottom_elements_holder"
/>
<LinearLayout
android:width="match_parent"
android:height="wrap_content"
android:id="@+id/bottom_elements_holder"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/recyclerview"
app:layout_constraintBottom_toBottomOf="parent">
<!-- Anything below the RecyclerView goes here -->
</LinearLayout>
</android.support.constraint.ConstraintLayout>
Вам, очевидно, потребуется изменить его в соответствии с вашими потребностями.
С ConstraintLayout вы можете установить высоту RecyclerView равной match_constraint
(0dp
) и установите его верхнее и нижнее ограничения.Если у вас есть элементы над RecyclerView, поместите их в верхний LinearLayout, и то же самое для нижнего.
Для получения дополнительной информации о том, как работает ConstraintLayout, вы должны прочитать документацию .