事件传递的总结图

https://www.processon.com/diagraming/5a72ba1be4b0874437b58c4f

处理特殊图形点击事件的几种方式 :

通过path绘制特殊的点击范围, 放入Region中 然后通过contains是否包含即可

兼容onClick1:

1
2
3
4
5
@Override
public boolean dispatchTouchEvent(MotionEvent event) {
return isEventInPath(event)?super.dispatchTouchEvent(event);
}
参考:http://blog.csdn.net/qibin0506/article/details/52676670

兼容onClick2:

1
2
3
4
@Override
public boolean onTouchEvent(MotionEvent event) {
return isEventInPath(event)?super.onTouchEvent(event):false;
}

自己的回调监听:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
@Override
public boolean onTouchEvent(MotionEvent event) {
switch (event.getActionMasked()) {
mListener.onCenterCliched();//
}
return true;
}
// 点击事件监听器
public interface MenuListener {
void onCenterCliched();
}
参考:http://www.gcssloop.com/customview/touch-matrix-region