mScaleGesture = new ScaleGestureDetector(this, new ScaleGestureDetector.OnScaleGestureListener() {
@Override
public boolean onScale(ScaleGestureDetector detector) {
mScaleFloat *= detector.getScaleFactor();
String str = “”;
str = “比例:”+detector.getScaleFactor()+” mScaleFloat:”+mScaleFloat+”\n”;
mScaleFloat = Math.max(0.1f,Math.min(mScaleFloat,5.0f));//图像比例,最小0.1,最大5
str += ” mScaleFloat:”+mScaleFloat;
text2.setText(str);
matrix.setScale(mScaleFloat, mScaleFloat);
img.setImageMatrix(matrix);
img.invalidate();
return true;//这里一定要返回真,否则不会继续监听事件
}
近期评论