12

I have a ViewPager widget in every row of a ListView. This provides a shelf-like UI, so the user can scroll around searching for a shelf vertically, and then scroll horizontally amongst the contents of a shelf. This works.

But the scrolling experience is terrible: if I start to drag a shelf's ViewPager, scroll it horizontally, and accidentally drag a bit upwards/downwards, then the ListView "traps" this dragging action, and start to scroll vertically, ending my horizontal drag. In this state, the drag action won't "return" to the ViewPager, the ListView has it, and that's it. I have to start another drag action to affect the ViewPager again. So I guess the ListView has precedence in these cases.

How can this be fixed? I'd like to achieve the exact opposite: If the ViewPager inside a list row starts reacting to a horizontal drag, then it should trap that action, and this drag should stop affecting the ListView, no matter how the user moves his/her finger vertically. Can this be done?

Zsombor Erdődy-Nagy
  • 16,864
  • 16
  • 76
  • 101
  • 7
    Found the answer, here: http://stackoverflow.com/questions/2646028/android-horizontalscrollview-within-scrollview-touch-handling – Zsombor Erdődy-Nagy Oct 26 '11 at 16:32
  • In that case, the best thing to do is close this question as a duplicate (if you feel the questions were close enough), or if they're different enough, submit the link as an answer, and mark it as the "selected answer". That way it won't show up as an upvoted, unanswered question anymore :) – Alexander Lucas Sep 13 '12 at 17:53
  • You're right, this question displayed as being unanswered is confusing, I've added a proper answer. I think it's different enough, I wouldn't mark it as an exact duplicate. – Zsombor Erdődy-Nagy Sep 13 '12 at 18:51
  • Hi @ZsomborErdődy-Nagy can you please tell me how to add view pager as list view row ?? – Gaurav Arora Nov 13 '13 at 16:23

1 Answers1

3

I've found a solution in this thread. There the problem is to handle touch events properly for a HorizontalScrollView inside a regular ScrollView, but the solution to that problem seems to apply to this one too.

Community
  • 1
  • 1
Zsombor Erdődy-Nagy
  • 16,864
  • 16
  • 76
  • 101