2
votes

I have an ImageView which I want to smoothly zoom on double tap.

Currently I have zoom working like this

        public boolean onDoubleTap(MotionEvent e) {
        ImageView imageView = (ImageView) findViewById(imageViewId);
         int width = imageView.getWidth();
         int height = imageView.getWidth();
         float maxScale;
         if ( width < height ) {
         maxScale = (float) (width * Math.pow(1.5, 6));
         } else {
         maxScale = (float) (height * Math.pow(1.5, 6));
         }

         Drawable d = imageView.getDrawable();
         int imageWidth = d.getIntrinsicWidth();
         int imageHeight = d.getIntrinsicHeight();
         float[] value = new float[9];
         matrix.getValues(value);
         scaleWidth = (int)(imageWidth * value[Matrix.MSCALE_X]);
         scaleHeight = (int)(imageHeight * value[Matrix.MSCALE_Y]);

         if ( (scaleWidth * 2) < maxScale ) {
         matrix.postScale(2, 2, e.getRawX(), e.getRawY());
         } else {
         matrix.postScale(0, 0, e.getRawX(), e.getRawY());
         }
         isDoubleTab = true;
         tuneMatrix(matrix);
         savedMatrix.set(matrix);
        return false;
    }

It's not smooth at all. I googled a lot, but wasn't able to find any working solution for DoubleTap. Any ideas?

1

1 Answers

5
votes

Here is a good link for imageZoom on double tap... http://blog.sephiroth.it/2011/04/04/imageview-zoom-and-scroll/