draw dots on simple clicking

This commit is contained in:
tibbi 2016-02-15 21:26:30 +01:00
parent 717a629d09
commit 3af4509b1c
1 changed files with 11 additions and 0 deletions

View File

@ -14,6 +14,8 @@ public class MyCanvas extends View {
private Path path; private Path path;
private float curX; private float curX;
private float curY; private float curY;
private float startX;
private float startY;
public MyCanvas(Context context, AttributeSet attrs) { public MyCanvas(Context context, AttributeSet attrs) {
super(context, attrs); super(context, attrs);
@ -45,6 +47,13 @@ public class MyCanvas extends View {
private void actionUp() { private void actionUp() {
path.lineTo(curX, curY); path.lineTo(curX, curY);
// drawing dots
if (startX == curX && startY == curY) {
path.lineTo(curX, curY + 2);
path.lineTo(curX + 1, curY + 2);
path.lineTo(curX + 1, curY);
}
} }
@Override @Override
@ -54,6 +63,8 @@ public class MyCanvas extends View {
switch (event.getAction()) { switch (event.getAction()) {
case MotionEvent.ACTION_DOWN: case MotionEvent.ACTION_DOWN:
startX = x;
startY = y;
actionDown(x, y); actionDown(x, y);
invalidate(); invalidate();
break; break;