draw a single-touch motion path in android

ε祈祈猫儿з 提交于 2019-12-22 05:11:57

问题


i am trying to make a drawing application.

i want to draw a single-touch motion path in android - like the way the Swype keyboard does it.

And consequently i want to store x-y coordinates of EACH of the pixels of the motion path into a data structure.

How can i use the MotionEvent pointers to do this?


回答1:


You probably don't have to store every pixel - just store a new one when certain parameters are met such as the pixel is further along or if the angle between one pixel and the next is greater than a certain threshold. From that you'll have a more compact poly line that will be easier to work with.




回答2:


You should look how to handle touch events here : http://developer.android.com/guide/topics/ui/ui-events.html

The example in the documentation of MotionEvent ( http://developer.android.com/reference/android/view/MotionEvent.html ) shows you how to get the coordinates of the touch event motion.

Then all you have to do is draw it (and maybe smooth it up a little)



来源:https://stackoverflow.com/questions/5202315/draw-a-single-touch-motion-path-in-android

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