Hi, I'm trying to do easy app for draw on screen. I followed the tutorial on Graphics | Android Developers.
In my onTouchEvent method I have:
But when I draw, it shows something like that:
so I draw another lines and image changes to
In constructor of my MySurface class (which extends SurfaceView and implements SurfaceHolder.Callback) i set up holder variable:
Does anybody know what is wrong?
In my onTouchEvent method I have:
Code:
_canvas = holder.lockCanvas();
if (event.getAction() == MotionEvent.ACTION_DOWN) {
_path = new Path();
_path.moveTo(event.getX(), event.getY());
_path.lineTo(event.getX(), event.getY());
} else if (event.getAction() == MotionEvent.ACTION_MOVE) {
_path.lineTo(event.getX(), event.getY());
_canvas.drawPath(_path, mPaint);
_path = new Path();
_path.moveTo(event.getX(), event.getY());
} else if (event.getAction() == MotionEvent.ACTION_UP) {
_path.lineTo(event.getX(), event.getY());
_canvas.drawPath(_path, mPaint);
}
holder.unlockCanvasAndPost(_canvas);
so I draw another lines and image changes to
In constructor of my MySurface class (which extends SurfaceView and implements SurfaceHolder.Callback) i set up holder variable:
Code:
holder = getHolder();
holder.addCallback(this);
Does anybody know what is wrong?