swipe effect like in samsung phone calling and message [duplicate]

放肆的年华 提交于 2019-12-04 17:58:25

Have a look at this git repo.. This may well be what you are searching for.. 47Deg

Yes you can do using fling gesture
Some code to help you

 SimpleOnGestureListener mySimpleGestureListener = new SimpleOnGestureListener()
{

@Override
public boolean onDoubleTap(MotionEvent e) { 
    Logout.debug("onDoubleTap");
    return super.onDoubleTap(e);
}

@Override
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX,float velocityY) 
{
    String velocity="onFling: \n" + e1.toString() + "\n" + e2.toString() +"\n"
            + "velocityX= " + String.valueOf(velocityX) + "\n"
            + "velocityY= " + String.valueOf(velocityY) + "\n";
    Logout.debug("onFling velocity="+velocity);
                return super.onFling(e1, e2, velocityX, velocityY);
}

@Override
public void onLongPress(MotionEvent e) {
    Logout.debug("onLongPress: \n" + e.toString());
    super.onLongPress(e);
}

@Override
public boolean onSingleTapConfirmed(MotionEvent e) {
    Logout.debug("onSingleTapConfirmed: \n" + e.toString());
    return super.onSingleTapConfirmed(e);
}

private boolean permissibleYVelocity(float velocityY)
{
    if ((velocityY < -200) || (velocityY > 200))
    {
        return false;
    }
    else
    {
        return true;
    }

}
};

GestureDetector myGestureDetector = new GestureDetector(mSimpleOnGestureListener);

View.OnTouchListener mOnListTouchListener = new  OnTouchListener()
{
@Override
public boolean onTouch(View view, MotionEvent event)
{
    Logout.debug("list onTouch()");
     return myGestureDetector.onTouchEvent(event);
}
};
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!