0

Possible related question:Adding Fling Gesture to an image view - Android

This is what I want:

An imageview-menu, single view, one image shown at a time, when swipe up or down, change the picture accordingly thus enabling users to access different functions.

This is what I plan to do:

Use guesture dector, combining with ontouch event, to detect the down/initial finger contact position then the up/last finger contact position, do a simple math, and figure out if the user had swiped up or down, and execute relevant events accordingly.

This is the problem:

I failed to find a simpler solution and I cannot believe android actually don't have a swipe up/down/left/right event for views, not even imageview.

My questions are:

  1. Will my plan work?
  2. Is it the optimal/easiest solution, am I overcomplicating things, as in, there absolutely is a dedicated mechanism built in android tot listen to swipes?
VictorCharlie23
  • 121
  • 1
  • 10

2 Answers2

0

Use Touch listener . Take the coordinates of the touch down and up.

check whether swipe up,down,left right from the touch listener using coordinates using simple math function.

Tomin B Azhakathu
  • 2,656
  • 1
  • 19
  • 28
0

There's a gesture detector in Android, and the answer here gives an example on how to use it with flinging up and down on a view.

And to answer the question "Is there a really easy way?". Not really, but you you can use this. Good luck!

Daniel Arena
  • 117
  • 11