Xamarin
A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
4,930 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
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>
Thank you LeonLu for your quick response.
Please check example below.
If i will use old ViewPager instead Viewpager2 everything is working fine.
I have upload two examples Old ViewPager and Viewpager2. Please check the difference.
I need when i am scrolling recyclerview vertical, viewpager's swipe to be disabled. Only when i am scrolling horizontal viewpager's to be enabled.
I believe that there is an option for doing that. As i notice old ViewPager is working exactly as expected.
ViewPager2
ViewPager2 Example Download
Old Viewpager
Old ViewPager Example Download
You can try to set
viewPager.UserInputEnabled = false;
to disable the viewpage's swipe guesture. Then mintor the activity swipe right and left guesture to enableUserInputEnabled
.