Android Gallery with pinch zoom
Asked Answered
F

2

17

I found a sample project of gallery with pinch zoom and made some bug fix. You can download my code at here

It supports full screen only. It always center the image to screen height. But I want to put a header view to the top of the screen and make the adjustment to the location of the image. The image location should be:

header height + (screen height - header height) / 2

I am not so good at using Matrix. Anyone has idea of how to make the customized gallery to work in any size (not just full screen)?

Felix answered 22/4, 2012 at 14:32 Comment(4)
This is great stuff. Can you please explain the main fixes?Henslowe
When i set the imageview scaltype to fitxy from Matrix, the zoom is not working..why is this happeningWalk
This is the best(and simplest) photo gallery I found, but it has some glitches, like images pushed to the right or bottom of the window after swiping or zooming. Also, it doesn't let you zoom all the way in. Also, it zooms out too much if the image is in low resolution.Henslowe
You might have answers in this project: github.com/sephiroth74/ImageViewZoom. I think they calculate the height/width according to the ImageView and not screen size.Henslowe
T
2

You can use my Pinch to zoom Gallery project. You can choose any image from gallery and then in onDoubleTap(MotionEvent e) open full image and zoom it.

Talkie answered 21/11, 2012 at 21:28 Comment(1)
first of all +1 vote for your project link , i test it and working perfectly , but i have bounty question related to same subject can you check it please : #18229434 , also how can i utilize your project to achieve zooming ability in my infinite gallery and does i need to use all classes in your project , thanks alotPaiz
T
0

You can do Image Zoom pinch option for gallery also by using below code lines:

case MotionEvent.ACTION_POINTER_DOWN:
    oldDist = spacing(event);
    Log.d(TAG, "oldDist=" + oldDist);
    if (oldDist > 10f) {
        savedMatrix.set(matrix);
        midPoint(mid, event);
        mode = ZOOM;
        Log.d(TAG, "mode=ZOOM" );
    }
    break;

Or you can download the example.

Tishatishri answered 19/11, 2012 at 7:0 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.