大家。我在SurfaceView的顶部绘制了一个矩形,其中包含XY的乞讨点的Motion Event。在绘制矩形后,我想知道如何拉开它的边缘?
我的代码:
protected void onDraw(Canvas canvas) {
if(drawing){
canvas.drawRect(Var.Numb3,Var.Numb4,Var.Numb,Var.Numb2, paint);
}
}
@Override
public boolean onTouchEvent(MotionEvent event) {
int action = event.getAction();
if (action==MotionEvent.ACTION_MOVE){
float x = event.getX();
float y = event.getY();
Var.Numb = Var.X ;
Var.Numb2 = Var.Y ;
Var.Numb3 = (int) x;
Var.Numb4 = (int) y ;
}
else if (action==MotionEvent.ACTION_DOWN){
Var.X = (int) event.getX();
Var.Y = (int) event.getY();
drawing = true;
}
else if (action==MotionEvent.ACTION_UP){
drawing = true;
}
invalidate();
return true;
}
}