开发者

SimpleOnScaleGestureListener only receives onScaleBegin event

I'm trying to implement an onscalegesturelistener. My problem is, that the SimpleOnScaleGestureListener only receives the onScaleBegin event. The other events aren't being reported. I'm using a Nexus One for testing

public class ZoomHandler开发者_如何学C extends SimpleOnScaleGestureListener {

public float zoom;

public ZoomHandler(float zm) {
    this.zoom = zm;
}

public boolean onScale(ScaleGestureDetector arg0) {
    Log.i("SCALE", "onscale " + arg0.getScaleFactor());
    this.zoom *= arg0.getScaleFactor();

    // Don't let the object get too small or too large.
    this.zoom = Math.max(0.1f, Math.min(this.zoom, 5.0f));

    return true;
}

@Override
public boolean onScaleBegin(ScaleGestureDetector arg0) {
    Log.i("SCALE", "onscalebegin " + arg0.getScaleFactor());
    return false;
}

@Override
public void onScaleEnd(ScaleGestureDetector arg0) {
    Log.i("SCALE", "onscaleend " + arg0.getScaleFactor());
}

}

In the activity I'm doing this:

....

mScaleDetector = new ScaleGestureDetector(this , new ZoomHandler(this.zoom));

@Override
public boolean onTouchEvent(MotionEvent event) {
    this.mScaleDetector.onTouchEvent(event);
    .....
}
....

Thanks a lot


The return values of onScaleBegin() and onScale() control whether or not to continue with the sequence. If onScaleBegin() returns false, as yours does, none of the others will run.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜