I have class that extends View.
private class Draw2D extends View{
public Draw2D(Context context) {
super(context);
}
@Override
public boolean onTouchEvent(MotionEvent event) {
x = event.getX();
y = event.getY();
switch(event.getAction()){
case MotionEvent.ACTION_MOVE:{
break;
}
}
return super.onTouchEvent(event);
}
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
Paint paint = new Paint();
paint.setStyle(Paint.Style.FILL);
paint.setColor(Color.WHITE);
ShapeDrawable rectangle =
new ShapeDrawable(new RectShape());
rectangle.getPaint().setColor(Color.GRAY);
rectangle.getPaint().setStyle(Paint.Style.STROKE);
rectangle.getPaint().setStrokeWidth(3);
rectangle.setBounds(50, 30, 200, 150);
rectangle.draw(canvas);
}
}
I want to moving my shape follow the finger on screen.
What I should write in MotionEvent.ACTION_MOVE to do what I want?
These Youtube tutorials do just this;
Link:
https://buckysroom.org/videos.php?cat=6
Just watch the tutorials 71, 72 and 73 and it should work.