标签:io ar sp on art cti bs amp ef
网易新闻中有个比较炫的效果,在QQ进入聊天界面也有这种效果,就是从界面左侧滑动到右侧时,界面退出,其实功能很容易实现:
1)
Activity 去实现 implements OnTouchListener
2) 实现其中的onTouch方法:
/**
* 左滑动返回监听
*/
@Override
public boolean onTouch(View v, MotionEvent event) {
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
startX = event.getX();
startY = event.getY();
break;
case MotionEvent.ACTION_UP:
float endX = event.getX();
float endY = event.getY();
if(Math.abs(endX-startX)>150&&((endY-startY)==0||Math.abs((endX-startX)/(endY-startY))>2)){
finish();
}
break;
default:
break;
}
return false;
}
标签:io ar sp on art cti bs amp ef
原文地址:http://www.cnblogs.com/androidsuperman/p/4080249.html