Horizontal Viewpager2 and Vertical Recyclerview issue

Dimitris Christoforidis 296 Reputation points
2022-02-10T10:33:40.967+00:00

I am using a horizontal viewpager2 and a vertical Recyclerview inside. So sometimes when i scrolling to the end or to the top of recyclerview (Vertical) it changes page in viewpager2 . How is this possible to fix it?

In my main page xml

<com.google.android.material.tabs.TabLayout
    android:id="@+id/tabLayout"
    android:layout_width="match_parent"
    android:layout_height="40dp"
    app:tabMode="scrollable" />

<androidx.viewpager2.widget.ViewPager2
    android:id="@+id/viewPager"
    android:layout_width="match_parent"
    android:layout_height="match_parent" />

Recyclerview fragment xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <androidx.recyclerview.widget.RecyclerView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:id="@+id/InventoryList"/>

</LinearLayout>
Xamarin
Xamarin
A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,292 questions
{count} votes