0

I have a ViewPager, that contains a RecyclerView which scrolls vertically and displays items with an adapter. Each item haves a NestedScrollView, which also should scroll vertically. The problem is that when I try to scroll that NestedScrollView, it scrolls the parent ViewPager.

How can i solve this problem?

This is the RecyclerView:

<androidx.recyclerview.widget.RecyclerView
    android:id="@+id/offersRecyclerView"
    android:layout_width="0dp"
    android:layout_height="0dp"
    android:background="@drawable/table_cell_background"
    android:fadeScrollbars="false"
    android:scrollbars="vertical"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent" />

This is the layout of the items, which contains the NestedScrollView:

    <androidx.constraintlayout.widget.ConstraintLayout
        android:id="@+id/statusConstraintLayout"
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:background="@drawable/table_background"
        android:padding="@dimen/spacing_small"
        app:layout_constraintStart_toEndOf="@+id/salaryConstraintLayout"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintWidth_percent="0.55">

        <androidx.core.widget.NestedScrollView
            android:layout_width="0dp"
            android:layout_height="0dp"
            android:orientation="vertical"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent">

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content">
                <TextView
                    android:id="@+id/statusValue"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="@string/offer_sent_with_three_dots"
                    android:textSize="@dimen/mini_text"
                    app:layout_constraintStart_toStartOf="parent"
                    app:layout_constraintTop_toTopOf="parent" />
            </LinearLayout>
        </androidx.core.widget.NestedScrollView>
    </androidx.constraintlayout.widget.ConstraintLayout>
2
  • Is the ViewPager vertical or horizontal? Commented Aug 29, 2020 at 23:11
  • Also, I haven't tested this so it may or may not work, but give ViewPager2 a try: it's based on RecyclerView and thus should handle nested scrolling a bit better. Commented Aug 29, 2020 at 23:13

2 Answers 2

2

Also you can try this in the RecyclerView

android:nestedScrollingEnabled="true"
Sign up to request clarification or add additional context in comments.

1 Comment

Can the items layout of ConstraintLayout be restricted on layout_height. Here match parent is used. Can you change to wrap_content instead and check?
0

try with by add this attribute app:layout_behavior="@string/appbar_scrolling_view_behavior" to nestedScrollView

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.