Do you know the touch event is actually in UI thread? Even if you called the invalidate, the canvas will not draw anything until your whole code block has been executed. That means the system will render the UI after your code
for (int loop=move;loop>0;loop--)
that's why you found always move to the end position. You should move your code to
case MotionEvent.ACTION_MOVE
. Don't use loop in an event. just make calculation once by every touch event. For example, globally declare a variable, and increase value by touchEvent
int a = 0;
public boolean onTouchEvent(MotionEvent event) {
final int x = (int)event.getX();
final int y = (int)event.getY();
int action = event.getAction();
switch (action) {
case MotionEvent.ACTION_MOVE:
++a;
invalidate();