Skip to content

Instantly share code, notes, and snippets.

@chrishuan9
Created April 28, 2012 07:32
Show Gist options
  • Save chrishuan9/2516867 to your computer and use it in GitHub Desktop.
Save chrishuan9/2516867 to your computer and use it in GitHub Desktop.
draw on surfaceview onDraw
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
canvas.restoreToCount(1);
canvas.clipRect(new Rect(0, 0, getWidth(), getHeight()));
canvas.drawCircle(x, y, 10, paint);
canvas.save();
}
float x,y;
@Override
public boolean onTouchEvent(MotionEvent event) {
x=event.getX();
y=event.getY();
invalidate();
return true;
}
canvas.drawCircle(100, 100, 5, paint); //it is drawing fine
//while i am using like this :
canvas.drawCircle(x, y, 5, paint); //it's not drawing.x,y being some points on screen and they are floats.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment