开发者

Smooth image zoom on Double Tap

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 ma开发者_JAVA百科xScale;
         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?


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜