Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android: RecyclerView within vertical viewpager

I want to implement a recyclerview within a vertical viewpager. My current layout looks like the following

VerticalViewpager
- Fragment1
    - ImageView
- Fragment2 
    - RecyclerView

If I swipe from Fragment1 to Fragment2 everything works fine. I am able to scroll within the recyclerview up and down. The problem occurs if I try to swipe/scroll back to Fragment1.

If the user has scrolled to the top of the recyclerview, I would like to forward the next "Up"-Scroll event to the vertical viewpager. I have tried overriding the onInterceptTouchEvent method, but unfortunately still no success. Any ideas out there? Thanks for your help :)

like image 880
jennymo Avatar asked Apr 04 '16 08:04

jennymo


2 Answers

You need do disable the scroll. Try using recyclerView.setNestedScrollingEnabled(false);

like image 67
Mr.India Avatar answered Oct 13 '22 02:10

Mr.India


1) You need to use support library 23.2.0 (or) above 2) and recyclerView height will be wrap_content. 3) recyclerView.setNestedScrollingEnabled(false)

But by doing this the recycler pattern don't work. (i.e all the views will be loaded at once because wrap_content needs the height of complete recyclerView so it will draw all recycler views at once. No view will be recycled). Try not to use this pattern util unless it is really required.

like image 40
Ashok Varma Avatar answered Oct 13 '22 02:10

Ashok Varma