在viewflipper放大图像 [英] zooming image in viewflipper
问题描述
我已经使用ViewFlipper创建的图像幻灯片。 我已经使用imageFrame.setOnTouchListener(gestureListener);听喜欢单一的自来水用户的触摸事件,长按
I have created a image slideshow using ViewFlipper. I have used imageFrame.setOnTouchListener(gestureListener); to listen user touch events like single tap,long tap
但现在我要放大/缩小当前图片的幻灯片(ViewFlipper),在doubletap通过user.I搜索上网本,但没有能够找到一个solution.Please帮助我。
But now i want to zoom in/out on current image in slideshow (ViewFlipper) ,on doubletap by user.I have searched internet for this but wasn't able to find a solution.Please help me out.
推荐答案
有许多方法可以做到这一点,但一个简单的方法是使用平台的 ZoomControls小部件,这是一个简单的小工具包括一个+/-按钮。您可以将 onZoomInClickListener
和 onZoomOutClickListener
来处理触摸到了ZoomControls部件。
There are a number of ways you can do this, but a simple way is to use the platform's ZoomControls widget, which is a simple widget consisting of a +/- button. You can attach onZoomInClickListener
and an onZoomOutClickListener
to handle touches to the ZoomControls widget.
在你处理,你可以扩展你的形象。下面是一个使用ScaleAnimation做变焦一些示例code:
In your handler, you can scale your image. Here's some sample code that uses a ScaleAnimation to do the zooming:
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);
}
});
这篇关于在viewflipper放大图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!