Sve*_*ver 2 android zoom imageview
我有一个想要在双击时平滑放大的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;
}
Run Code Online (Sandbox Code Playgroud)
这根本不顺利.我google了很多,但无法为DoubleTap找到任何有用的解决方案.有任何想法吗?
| 归档时间: |
|
| 查看次数: |
13653 次 |
| 最近记录: |