开发者

what is the gesture coordinate of a view on android

When using GestureDetector to capture gesture on screen, I'm confused by android's screen X-Y coordinate. For example:

class TouchPadGL extends GestureDetector.SimpleOnGestureListener {
    public boolean onScroll(MotionEvent e1, MotionEvent e2,
                            float distanceX, float distanceY) {
        Log.i("onScroll",String.format("dsX: %s, dsY: %s",distanceX,distanceY));
    }
    public boolean onFling(MotionEvent e1, MotionEvent e2, 
                           float velocityX, float velocityY) {
        Log.i("onFling",String.format("vX: %s, vY: %s",velocityX,velocityY));
    }
}

According to output of the above onScroll method, it's seemed the point (0,0) is at the right-down corner of the view, with the X-axe 开发者_开发百科stretch to left and Y-axe stretch upward. But when check the output of the onFling method, you will found that it's seemed (0,0) is at the top-left corner and X-axe stretch to right and Y-axe stretch downward. why could that happen ?

Is is a bug in the android api or i take it wrong ?

BTW, the code is run on API 2.1


the docs say:

distanceX The distance along the X axis that has been scrolled since the last call to onScroll. This is NOT the distance between e1 and e2.

distanceY The distance along the Y axis that has been scrolled since the last call to onScroll. This is NOT the distance between e1 and e2.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜