Reputation: 5594
I have some text on circles, and I would like the user to be able to touch and drag the text, and have it constrained to move along the circle...
I got this far using Canvas, but I can't figure out how to make it respond to touch this way. I am not objected to starting over and taking a non-canvas approach.
How can I make this happen? Pseudocode would be appreciated.
Upvotes: 1
Views: 528
Reputation: 45942
I might be wrong, but considering this is a canvas. Then, it is your job to detect which text is touched.
Once you set your onTouchListener for the view, you get the event coordinates of the ACTION_DOWN event. You check and get the text that was touched. If none, return false. Else, return true.
Now, if the user moves his finger, you will receive more events with ACTION_MOVE. In that case, you would probably want to move the chosen text according to the difference between this event and the last one. Once you calculate the new position of the texts, you call invalidate()
which should force a redraw.
Finally, when the user stops moving, you will receive an event with ACTION_UP. That is when you have to either put the texts back to their original position, or whatever you want.
Upvotes: 2