I am developing an application and requirements are as below.
Display image with pinch zoom and pan.
For this I am using TouchImageview.java from here
And it is working as expected.
Draw solid circle on Image.
This is also working.
public class NavigationViewZoom extends TouchImageView {
private Paint mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
@Override
public void setImageBitmap(Bitmap bm) {
super.setImageBitmap(bm);
}
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
canvas.drawCircle(300, 120, 50, mPaint);
}
public NavigationViewZoom(Context c) {
super(c);
init();
}
public NavigationViewZoom(Context c, AttributeSet attrs) {
super(c, attrs);
setDrawingCacheEnabled(true);
init();
}
private void init() {
mPaint.setColor(Color.RED);
mPaint.setStyle(Paint.Style.FILL);
}
}
Problem:
Now the problem is, when zoom in/out image after drawing solid circle on canvas the circle position is not managed.
For Example I draw solid circle on position x=100,y=100 after zooming the image the circle should be on same position. So how to get the relative x,y position on zoomed image.
Try using this library. In demo app is shown a feature that seems to do what you want.
CircleView class in the library could be useful.