0

I have a ViewPager. Inside this ViewPager I have Fragments that have all the same layout. The layout contains a header and a RecyclerView and I want only the header of this layout to be swipeable. So the user may only switch between the fragments inside the viewpager when he is swipping on the header. I have tried a CustomViewPager but it was not working the way I wanted it to.

Does someone have a solution?

Cimoe
  • 580
  • 6
  • 21
  • did you refer this ?? https://stackoverflow.com/a/7814054/3872374 – Omar Dhanish Aug 11 '17 at 12:02
  • @OmarDanisha Yes. Two problems that I have: On the first touch on the header, where i set swipeEnabled to true, the viewpager does not swipe. So I have to swipe twice. Second problem: Where do I set swipeEnabled to false when I touch a view that is not the header? – Cimoe Aug 11 '17 at 12:36

1 Answers1

0

My dirty but working solution is to set a custom TouchListener to my header view and every time it detects a fling to the right or left I call setCurrentItem(index, true) with the ViewPager. It is not the optimal solution, but is working for now.

Cimoe
  • 580
  • 6
  • 21