Android Gallery with pinch zoom

对着背影说爱祢 提交于 2019-11-26 19:38:04

问题


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)?


回答1:


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.




回答2:


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.



来源:https://stackoverflow.com/questions/10268806/android-gallery-with-pinch-zoom

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!