Вложенный в ScrollView ViewPager с RecyclerView

Имеется такая ситуация: ScrollView -> ViewPager -> RecyclerView.

<ScrollView
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:overScrollMode="never"
    android:scrollbars="none"
    android:fillViewport="true">

    <androidx.constraintlayout.widget.ConstraintLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

            <androidx.viewpager2.widget.ViewPager2
                android:id="@+id/viewPagerTasksGoalsMenu"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_marginTop="8dp" />
    </androidx.constraintlayout.widget.ConstraintLayout>
</ScrollView>

Дальше я в коде помещаю во ViewPager фрагмент:

<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="wrap_content">

    <TextView
        android:id="@+id/textMenuTasksInfo"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

    <androidx.recyclerview.widget.RecyclerView
        android:id="@+id/list_tasks_launcher"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:clipToPadding="false"
        android:orientation="vertical"
        android:overScrollMode="never"
        android:paddingBottom="12dp"
        android:scrollbars="none"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@id/textMenuTasksInfo" />

</androidx.constraintlayout.widget.ConstraintLayout>

В итоге у меня листается RecyclerView. Но мне нужно, чтобы прокручивалась страница с этим RecyclerView. Грубо говоря, чтобы RecyclerView был статичен. Как это можно сделать?


Ответы (2 шт):

Автор решения: Wlad

Для того, чтобы он был статичен используется не ScrollView , а NestedScrollView(параметр fillviewport включен по умолчанию в Nested'е)

→ Ссылка
Автор решения: Виктор Шамрук

Решил проблему следующим образом:

        <androidx.core.widget.NestedScrollView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="8dp"
            android:overScrollMode="never"
            android:scrollbars="none"
            app:layout_constraintTop_toBottomOf="@id/scrollTasksGoalsTabs"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintEnd_toEndOf="parent">

            <androidx.viewpager2.widget.ViewPager2
                android:id="@+id/viewPagerTasksGoalsMenu"
                android:layout_width="match_parent"
                android:layout_height="wrap_content" />
        </androidx.core.widget.NestedScrollView>
→ Ссылка