I wanted to create a gallery with images. The images within the gallery should be zoomable and pannable. I could able to pinch-zoom an image but could not able to set zoom l
This fixed the zoom-limit problem for me. After the image is zoomed in/out to the limit, it just stops going further. It's also smooth and there are no lags. 0.7 and 2.0 are the minimum and maximum zoom levels.
....
} else if (mode == ZOOM) {
float[] f = new float[9];
float newDist = spacing(event);
if (newDist > 10f) {
matrix.set(savedMatrix);
float tScale = newDist / dist;
matrix.postScale(tScale, tScale, mid.x, mid.y);
}
matrix.getValues(f);
float scaleX = f[Matrix.MSCALE_X];
float scaleY = f[Matrix.MSCALE_Y];
if(scaleX <= 0.7f) {
matrix.postScale((0.7f)/scaleX, (0.7f)/scaleY, mid.x, mid.y);
} else if(scaleX >= 2.5f) {
matrix.postScale((2.5f)/scaleX, (2.5f)/scaleY, mid.x, mid.y);
}
}
....