如果用户使用scaleGestureDetector放大或缩小
,则无法区分mZoomGestureDetector = new ScaleGestureDetector(getActivity(), new OnScaleGestureListener()
{
int intFactor=0;
boolean firstVisited = false;
private float mScaleFactor2;
private float currectScale= -100;
private float startScale;
private float endScale;
@Override
public void onScaleEnd(ScaleGestureDetector detector)
{
endScale = detector.getScaleFactor();
//this condition does not pass. not > or < succeeds
if (startScale > endScale) {
Log.i("onScaleEnd", "Pinch Dection");
} else if (startScale < endScale) {
Log.i("onScaleEnd", "Zoom Dection");
}
setFontSize(intFactor);
}
@Override
public boolean onScaleBegin(ScaleGestureDetector detector)
{
startScale = detector.getScaleFactor();
return true;
}
@Override
public boolean onScale(ScaleGestureDetector detector)
{
//Log.i("ScaleFactor", "Scale Factor original " + detector.getScaleFactor());
mScaleFactor = detector.getScaleFactor() * 100;
Log.i("ScaleFactor", "Scale Factor : On " + mScaleFactor);
intFactor = (int) mScaleFactor;
return true;
}
});
;
答案 0 :(得分:4)
我解决了它如下:
@Override
public boolean onScale(ScaleGestureDetector detector)
{
double scaleFactor = detector.getScaleFactor();
if (1.0f > scaleFactor) {
mode = 0;//Log.i("ScaleFactor", "Pinch Dection");
} else {
mode = 1;//Log.i("onScaleEnd", "Zoom Dection");
}
}