android开发:触摸屏触摸事件MotionEvent演示实例

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;//这里一定要返回真,否则不会继续监听事件
}

 
Copyright © 2008-2021 lanxinbase.com Rights Reserved. | 粤ICP备14086738号-3 |