Search code examples
androidzoomingviewflipperswipe

zoom in viewflipper images


I have a viewflipper that contain 3 images. these images are associated with onGestureListener for swipe action.I want to implement zoom in and zoom out effect on each of these images, for properly reading the writings on images. Is there some way out? Please help me with some example. Thanks


Solution

  • The question was already asked, but you can do it like this :

    iv = (ImageView) findViewById(R.id.imageview);
    zc = (ZoomControls) findViewById(R.id.zoom_controls);
    zc.setOnZoomInClickListener(new OnClickListener() {
        public void onClick(View v) {
            float oldZoom = currentZoom;
            currentZoom = currentZoom * 1.25;
            zc.setIsZoomOutEnabled(true);
            if (3.0 < currentZoom) {
                zc.setIsZoomInEnabled(false);
            }
            scaleAnim = new ScaleAnimation(oldZoom, currentZoom, oldZoom, currentZoom, 0, 0);
            scaleAnim.setFillAfter(true);
            iv.startAnimation(scaleAnim);
        }
    });
    zc.setOnZoomOutClickListener(new OnClickListener() {
        public void onClick(View v) {
            float oldZoom = currentZoom;
            currentZoom = currentZoom / 1.25;
            zc.setIsZoomInEnabled(true);
            if (0.33 > currentZoom) {
                zc.setIsZoomOutEnabled(false);
            }
            scaleAnim = new ScaleAnimation(oldZoom, currentZoom, oldZoom, currentZoom, 0, 0);
            scaleAnim.setFillAfter(true);
            iv.startAnimation(scaleAnim);
        }
    });
    

    Source : zooming image in viewflipper