i have been struggling doing a onDraw with photoview. I used another class to extend photoview and override the onDraw. I get the drawable and show it on the extended class. I then get the image that is being used and create a bitmap with it. I then get the image and create a new bitmap, then add that to the canvas. The canvas is then used for the ondraw. The coordinates are found by getting the width of the photoview and x off the photontap and then just doing x*width, then doing the same for y and then invalidate it. I have added the code below.
drawHandler.setOnPhotoTapListener(new OnPhotoTapListener() {
@Override
public void onPhotoTap(ImageView view, float x, float y) {
onTap( x* width, y*height);
}
});
}
public void onTap(float x, float y){
oldy = currenty;
oldx = currentx;
currenty = y;
currentx = x;
if(oldy!=null && oldx!=null) {
if(oldx!= x && oldy!=y) {
drawHandler.x = x;
drawHandler.y = y;
drawHandler.oldX = oldx;
drawHandler.oldY = oldy;
drawHandler.draw(canvas);
drawHandler.invalidate();
}
}
}
This is within the DrawHandler
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
Paint p = new Paint(Paint.ANTI_ALIAS_FLAG);
Log.d("Draw Method Accessed", "About to draw");
canvas.drawLine(x, y, oldX, oldY, black);
}
}
I dont know why it isn't drawing the line