How do I modify TouchImageView with double tap to zoom in and out?

后端 未结 5 765
无人及你
无人及你 2020-12-29 17:37

I am modifying the TouchImageView (https://github.com/MikeOrtiz/TouchImageView/issues) to have zoom in and out for when you double tap. I have started as per this post - How

5条回答
  •  隐瞒了意图╮
    2020-12-29 17:43

    Doubles the current zoom to zoom in, then returns to original zoom level:

    float oldScale = 1.0f;
    public void zoomIn() {
        LogUtil.i(TAG, "Zooming in");
        oldScale = saveScale;
        saveScale *= 2;
        matrix.setScale(saveScale, saveScale);
        setImageMatrix(matrix);
        invalidate();
    }
    
    public void zoomOut() {
        LogUtil.i(TAG, "Zooming out");
        saveScale = oldScale;
        matrix.setScale(saveScale, saveScale);
        setImageMatrix(matrix);
        invalidate();
    }
    

    You might want to translate the matrix to centre on the point the user double clicked.

提交回复
热议问题