0
votes

I need to set the zoom level of the image (in an ImageView) to the original state i.e where it just fits into the ImageView and all the zoom-in has been removed. what i have tried is to store the image matrix value at the time of opening the image (when it was fit to screen) and then on a 'reset' button click assign this value to the ImageView that was zoomed in (and might have a modified matrix); but its not helping.. also i am not sure if its just the related matrix that defines the zoom level of the image or there is something else as well that i need to set. my code snippet:

PS. 'zoomMatrix' is the image matrix at the time when the image has just opened n is fit to screen. 'touch' is the object of the class extending ImageView.

resetZoom.getItem().setOnMenuItemClickListener(

    new MenuItem.OnMenuItemClickListener() {
        public boolean onMenuItemClick(MenuItem item) {

            touch.setImageMatrix(touch.zoomMatrix);
            touch.setScaleType(ScaleType.MATRIX);
            touch.invalidate();

            return true;
        }
});
1
did you try ScaleType.FIT_XY? i think that is no zoom thats what you want right?JRowan
yeah i tried that. it fits the image exactly into the screen. but then i cant zoom in or drag again. and yes i want no zoom (basically the very initial state my image).50EC07
maybe you should switch setscaletype and setimagematrix, is it in the right order?JRowan
tried that as well. no luck :( i tried touch.setScaleType(ScaleType.CENTER_INSIDE) also, it zooms out the image but then again i cant drag/zoom in again. and the if i tap a point on image,it gets dislocated.50EC07
can you set to fit_xy when you dont want to zoom and matrix when you want to zoom, like back and forthJRowan

1 Answers

-2
votes

you only need to do is, to implement this simple code in your reset button

setContentView(R.layout.activity_image);

this will reset your activity to its original scale/position...