title: Drawing on Android canvas
body: <p>I want to write a function drawCircle with 2 parameters x,y position. Whenever i touch on the screen, i will get x,y position and pass to the drawCircle function and draw a circle on the screen.</p>
  <p>MainActivity.java</p>
  <pre><code>public class MainActivity extends AppCompatActivity {
  private canvasview cv1;
  private double tx,ty;
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      getSupportActionBar().hide();
      cv1=new canvasview(this);
  
      setContentView(cv1);
      eventtouch();
  }
  
  public double gettx()
  {
      return tx;
  }
  public double getty()
  {
      return ty;
  }
  protected void eventtouch()
  {
  
      cv1.setOnTouchListener(new View.OnTouchListener() {
          @Override
          public boolean onTouch(View view, MotionEvent motionEvent) {
              tx=motionEvent.getX();
              ty=motionEvent.getY();
  
              return true;
          }
      });
  }
  </code></pre>
  <p>}</p>
  <p>canvasview.java</p>
  <pre><code>enter public class canvasview extends View {
  public canvasview(Context context)
  {
      super(context);
  }
  @Override
  protected void onDraw(Canvas canvas)
  {
      super.onDraw(canvas);
      Paint paint=new Paint();
      paint.setStyle(Paint.Style.FILL);
      paint.setColor(Color.rgb(250,250,250));
      canvas.drawPaint(paint);
  
      paint.setAntiAlias(true);
      paint.setColor(Color.BLUE);
      canvas.drawCircle(200,200,6,paint);
  }
  </code></pre>
  <p>}</p>