/**
* 手势监听
*
* @author lifengfeng
*
*/
public class MainActivity extends Activity implements OnTouchListener,
OnGestureListener {
// 创建一个用于识别收拾的GestureDetector对象
@SuppressWarnings("deprecation")
private GestureDetector detector = new GestureDetector(this);
// 新建一个LinearLayout布局对象,这里是指主页面的布局
private LinearLayout myLayout;
// 限制最小移动像素
private int FLING_MIN_DISTANCE = 110;
// 定义的Toast提示框显示时间
private int TIME_OUT = 1000;
private static final String TAG = "Main";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
myLayout = (LinearLayout) findViewById(R.id.test_layout);
// 为布局绑定监听
myLayout.setOnTouchListener(this);
}
/**
* 手势滑动时别调用
*/
@Override
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX,
float velocityY) {
// X轴的坐标位移大于FLING_MIN_DISTANCEÿ
android手势滑动——左右滑动效果实现
最新推荐文章于 2017-07-10 21:01:07 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)