页面中实现事件拦截方法:
VIew view;//是否点击到的view,是true
@Override
public void boolean OnInterceptTouchEvent(MotionEvent ev){
if(isTouchView(view,ev)){
//点击的是这个view
}
return supur.OnInterceptTouchEvent(ev);
}
public static boolean isTouchView(View v,MotionEvent ev){
boolean isTouch = false;
int eventx = (int)ev.getRawX();
int eventy = (int)ev.getRawY();
if(v !=null && v instanceof View){
int[] location = new int[2];
v.getLocationOnScreen(location);
int x = location[0];
int y = location[1];
int w = v.getWidth();
int h = v.getHeight();
Rect rect = new Rect();
rect.left = x;
rect.top = y;
rect.right = x+w;
rect.bottom = y+h;
if(rect !=null && rect.contains(eventx,eventy)){
isTouch = true;
}
return isTouch ;
}
}