如何在Zoom上绘制圆圈并滚动imageview android?

时间:2016-07-08 11:23:18

标签: android android-canvas pinchzoom touchimageview

我正在开发一个应用程序,要求如下。

使用捏拉缩放和平移显示图像。

为此我使用来自here

的TouchImageview.java

它按预期工作。

在图片上绘制实心圆圈。

这也有效。

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);

    }
}

问题:

现在的问题是,在画布上绘制实心圆圈后放大/缩小图像时,圆圈位置不会被管理。

例如我在缩放图像后,在位置x = 100,y = 100上绘制实心圆,圆圈应位于相同位置。那么如何在缩放图像上获得相对x,y位置。

1 个答案:

答案 0 :(得分:0)

尝试使用此library。 在演示应用程序中显示了一个似乎可以做你想要的功能。

CircleView库中的类可能很有用。