how to add a line as a gesture while moving from one image to another?

后端 未结 1 961
小鲜肉
小鲜肉 2020-12-18 17:18

I am making my own Pattern Lock for android phone, i have Done the coding as when i click on an image it stores an integer in an array and when the user re-enters the same p

相关标签:
1条回答
  • 2020-12-18 17:58

    Implement onTouchEvent(MotionEvent ev), with ACTION_DOWN, ACTION_MOVE, ACTION_UP. As your finger moving, draw a line from previous Coordinate to current Coordinate.
    Get coordinate by using ev.getX() ev.getY()
    I've just thought of two solution currently:

    1. When detecting touch event, at ACTION_DOWN, draw a transparent VIEW on top of parent view, make it Canvas and draw as long as ACTION_MOVE is under processing.

    2. Use SurfaceView instead of regular View. A sample on SurfaceView to draw: http://www.droidnova.com/playing-with-graphics-in-android-part-ii,160.html
    0 讨论(0)
提交回复
热议问题