接上
int dx = endX - mStartX;
int dy = endY - mStartY;
mLayoutParams.x += dx;
mLayoutParams.y += dy;
mWm.updateViewLayout(mCircleView, mLayoutParams);
mStartX = (int) event.getRawX();
mStartY = (int) event.getRawY();
break;
int dx = endX - mStartX;
int dy = endY - mStartY;
mLayoutParams.x += dx;
mLayoutParams.y += dy;
mWm.updateViewLayout(mCircleView, mLayoutParams);
mStartX = (int) event.getRawX();
mStartY = (int) event.getRawY();
break;
2016-09-02
老师的代码,滑动久了小球,会有偏移,下面是我修改的,主要修改了move事件
case MotionEvent.ACTION_MOVE:
mCircleView.setDragState(true);
int endX = (int) event.getRawX();
int endY = (int) event.getRawY();
case MotionEvent.ACTION_MOVE:
mCircleView.setDragState(true);
int endX = (int) event.getRawX();
int endY = (int) event.getRawY();
2016-09-02