Android 双击平滑图像缩放
我有一个图像视图,我想在双击时平滑地缩放它 目前我的zoom工作方式是这样的Android 双击平滑图像缩放,android,imageview,zooming,Android,Imageview,Zooming,我有一个图像视图,我想在双击时平滑地缩放它 目前我的zoom工作方式是这样的 public boolean onDoubleTap(MotionEvent e) { ImageView imageView = (ImageView) findViewById(imageViewId); int width = imageView.getWidth(); int height = imageView.getWidth();
public boolean onDoubleTap(MotionEvent e) {
ImageView imageView = (ImageView) findViewById(imageViewId);
int width = imageView.getWidth();
int height = imageView.getWidth();
float maxScale;
if ( width < height ) {
maxScale = (float) (width * Math.pow(1.5, 6));
} else {
maxScale = (float) (height * Math.pow(1.5, 6));
}
Drawable d = imageView.getDrawable();
int imageWidth = d.getIntrinsicWidth();
int imageHeight = d.getIntrinsicHeight();
float[] value = new float[9];
matrix.getValues(value);
scaleWidth = (int)(imageWidth * value[Matrix.MSCALE_X]);
scaleHeight = (int)(imageHeight * value[Matrix.MSCALE_Y]);
if ( (scaleWidth * 2) < maxScale ) {
matrix.postScale(2, 2, e.getRawX(), e.getRawY());
} else {
matrix.postScale(0, 0, e.getRawX(), e.getRawY());
}
isDoubleTab = true;
tuneMatrix(matrix);
savedMatrix.set(matrix);
return false;
}
一点也不顺利。我在谷歌上搜索了很多,但没有找到DoubleTap的有效解决方案。有什么想法吗?这里有一个双击图像缩放的好链接。。。
谢谢。这正是我所需要的,但不幸的是,我的应用程序是2.1,实现这一点依赖于2.2 ScaleGestureDetector。这让我很难过。最后我决定坚持2.2。很好。。2.1已过时。2.2在当前发行版中占有64.6%的份额…您可以将2.2中的ScaleGetureDetector移植到后端,并在不支持多点触摸的2.1早期版本上使用它。您应该确保只在未内置后端口类的平台上使用后端口类,因为较新的平台在2.2实现中存在问题。此库中的easing和cubing类在哪里