Created
April 28, 2012 07:32
-
-
Save chrishuan9/2516867 to your computer and use it in GitHub Desktop.
draw on surfaceview onDraw
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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