0

How can i detect which way i user swipes the picture if they swipe it right then (DO SOMETHING) if they swipe it left then (DO SOMETHING)

CheckRaise
  • 550
  • 2
  • 16

1 Answers1

0

you can get the array of screen touch locations from event.getX(x) (for example event.getX(0) means latest motion event and getX(1) means previous to latest). In this you can apply a formula to detect in which side are you swiping.

For Right.. { if(event.getX(0)- event.getX(1) > 0) // You swiped to right } and similarly for left (i.e. xxxxxx < 0).

Awais Tariq
  • 7,724
  • 5
  • 31
  • 54