问题
I need to handle 3 types of gestures in my app: points, lines and circles.
Circles and lines are vectored (may be drawn in different directions, like in windows 8 picture password).
Now I'm looking for a better way for it - read about GestureOverlayView
, but, how I understood, those gestures should be given initially, and my lines will be at different angles, and circles at different diameters.
Is there any easy way to do it, or better to use onTouchEvent
and detect gestures mathematically?
回答1:
When you said you "need to handle 3 types of gestures", what exactly do you mean by 'handle', ie. what do you need to do with the gestures? Do you mean that you need to determine if a particular gesture is a point, line or circle?
If you want to analyse a gesture, as it is being drawn or after it is drawn, you could create a Path object and update it in each onTouchEvent. Then you would do your mathematical calculations with the points along that Path. http://developer.android.com/reference/android/graphics/Path.html
来源:https://stackoverflow.com/questions/16506685/android-best-way-to-handle-point-line-and-circular-gestures