2
我有一个ImageView,我想平滑放大双击。双头水龙头上的平滑图像缩放
目前我有变焦这样
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)。这让我难过。 – Sver 2011-06-13 10:51:02
最后我决定坚持2.2。 – Sver 2011-06-15 09:13:32
不错.. 2.1已过时。 2.2在当前分配中占有64.6%的份额... http://developer.android.com/resources/dashboard/platform-versions.html – Sujit 2011-06-15 09:21:14