Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Conflict between ViewPager swipe and RecyclerView scroll

In my app, I have a ViewPager that has different tabs. Each tab is composed only of a RecyclerView which can be scrolled vertically.

My problem is that when I try to navigate to other tab and swipe left or right, the RecyclerView's scroll is detected first and instead of going to another tab the RecyclerView gets scrolled.

I tried following property of recycler view:

         rv_home.setNestedScrollingEnabled(false);

that time ViewPager swipe works as expected But vertical scrolling of recycler view disabled. What should I do?

like image 319
Liya Avatar asked Oct 21 '25 19:10

Liya


1 Answers

rv_home.setHasFixedSize(true);
RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(getApplicationContext(),
LinearLayoutManager.VERTICAL, false);
layoutManager.setAutoMeasureEnabled(true);
rv_home.setNestedScrollingEnabled(false);
rv_home.setLayoutManager(layoutManager);

try this

like image 174
Leyh Avatar answered Oct 23 '25 09:10

Leyh



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!