SwipeView类似桌面的滑动界面(12)
来源:未知 责任编辑:责任编辑 发表时间:2013-12-06 08:44 点击:次
}
private boolean actionDown(MotionEvent event)
{
mMotionStartX = (int) event.getX();
mMotionStartY = (int) event.getY();
mFirstMotionEvent = false;
return false;
}
private boolean actionMove(MotionEvent event)
{
int newDistance = mMotionStartX - (int) event.getX();
int newDirection;
if(newDistance<0) //backwards
{
newDirection = (mDistanceX+4 <= newDistance) ? 1 : -1; //the distance +4 is to allow for jitter
}
else //forwards
{
newDirection = (mDistanceX-4 <= newDistance) ? 1 : -1; //the distance -4 is to allow for jitter
}
if(newDirection != mPreviousDirection && !mFirstMotionEvent)//changed direction, so reset start point
{
mMotionStartX = (int) event.getX();
mDistanceX = mMotionStartX - (int) event.getX();
}
最新推荐更多>>>
- 发表评论
-
- 最新评论 更多>>