v.getLocalVisibleRect(rect); // 局部
v.getGlobalVisibleRect(rect); // 全局
v.getFocusedRect(rect); // ??
// 是否触摸到集合view
//mIgnoredViews = new ArraryList<View>();
private boolean isInIgnoredView(MotionEvent ev) {
Rect rect = new Rect();
for (View v : mIgnoredViews) {
v.getLocalVisibleRect(rect);
int x=(int)ev.getX();
int y=(int)ev.getY();
System.out.println("x = " + x);
System.out.println("y = " + y);
if (rect.contains(x,y)){
return true;
}
}
return false;
}
private class Gesturetor extends GestureDetector.SimpleOnGestureListener {
@Override
public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) {
if(isInIgnoredView(e1)){// 忽略添加的试图,手势无效
return false;
}
}