2

so I tried Zala's code for handling the gestures from this question android how to handle right to left swipe gestures, it works but the problem is my component is inside a scrollview so the gestures sometimes are detected sometimes not, I tried few different codes to solve this scrollview issue still the same behavior. Anyone could help please !

4
  • possible duplicate stackoverflow.com/questions/8330187/… Commented Apr 25, 2017 at 9:35
  • I have seen it still dosen't work for me Commented Apr 25, 2017 at 9:37
  • 1
    then try scrollview .setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View view, MotionEvent motionEvent) { return false; } }); Commented Apr 25, 2017 at 9:39
  • Possible duplicate of Detect swipe using onTouchListener in ScrollView Commented Nov 6, 2018 at 16:53

1 Answer 1

7
scrollView.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { switch(event.getAction()){ case MotionEvent.ACTION_DOWN:{ downX = event.getX();} case MotionEvent.ACTION_UP:{ upX = event.getX(); float deltaX = downX - upX; if(Math.abs(deltaX)>0){ if(deltaX>=0){ swipeToRight(); return true; }else{ swipeToLeft(); return true; } } } } return false; } }); 
Sign up to request clarification or add additional context in comments.

4 Comments

the swipe is not on the scrollview, its on a chart inside the scrollview
implement same event for chart view as well
It trigger the swipe left event when i am doing vertical scroll.
This will conflict with scroll view controller like recycleview etc.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.