How is make canvas Java to extension?

I make this on android studio i don’t know how make view become canvas
How make this become extension

public class MyCanvas extends View {

Rect rect;
Paint paint;
float xPos1 = 0;
float yPos1 = 0;
float xPos2 = 0;
float yPos2 = 0;

public MyCanvas(Context context) {
    super(context);
}

@Override
protected void onDraw(Canvas canvas) {
    super.onDraw(canvas);
  
    paint = new Paint();
    paint.setColor(Color.GREEN);
    paint.setStrokeWidth(40);
    paint.setStyle(Paint.Style.STROKE);
   canvas.drawCircle(xPos,yPos,100,paint);
   
}

@Override
public boolean onTouchEvent(MotionEvent event) {

  
        xPos1 = event.getX();
        yPos1 = event.getY();
        
   
    invalidate();
    return super.onTouchEvent(event);
}

}

First Type your Question Properly. Make it clear and understandable
Second there Already exist a canvas Components

Third Change the Category to Extension Request

Thank you

1 Like

I was changed