Android: best way to handle point, line and circular gestures

怎甘沉沦 提交于 2020-01-05 10:06:08

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!