放大viewflipper图像

时间:2012-07-20 08:06:12

标签: android zoom viewflipper swipe

我有一个包含3张图片的viewflipper。这些图像与onGestureListener相关联,用于滑动操作。我想在每个图像上实现放大和缩小效果,以便正确读取图像上的文字。还有出路吗?请帮我举个例子。感谢

1 个答案:

答案 0 :(得分:3)

问题已经提出,但你可以这样做:

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);
    }
});

来源:zooming image in viewflipper