在Android中的手势滑动

时间:2013-04-05 12:33:21

标签: android views swipe

关于轻扫手势我遇到了问题。我需要从主视图向右侧滑动到左侧。我使用Fling GestureDetector,手势正在检测,但如何我可以创建一个滑动视图

这里我使用了以下代码:

@Override
        public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX,
                float velocityY) {
            String swipe = "";
            float sensitvity = 50;

            // TODO Auto-generated method stub

            if((e1.getX() - e2.getX()) > sensitvity){
                swipe += "Swipe Left\n";
                SwipeLeft();
            }else if((e2.getX() - e1.getX()) > sensitvity){
                swipe += "Swipe Right\n";
            }else{
                swipe += "\n";
            }

            if((e1.getY() - e2.getY()) > sensitvity){
                swipe += "Swipe Up\n";
            }else if((e2.getY() - e1.getY()) > sensitvity){
                swipe += "Swipe Down\n";
            }else{
                swipe += "\n";
            }

            gestureEvent.setText(swipe);

            return super.onFling(e1, e2, velocityX, velocityY);
        }
    };

我需要的是这样的东西

enter image description here

有什么想法吗? @thanks

0 个答案:

没有答案