方法一:
[java] view plaincopy
- @Override
- public boolean onTouchEvent(MotionEvent event) {
- if (event.getAction() == MotionEvent.ACTION_DOWN) {
- if (!(event.getX() >= -10 && event.getY() >= -10)
- || event.getX() >= calendarLayout.getWidth() + 10
- || event.getY() >= calendarLayout.getHeight() + 20) {//如果点击位置在当前View外部则销毁当前视图,其中10与20为微调距离
- finish();
- }
- }
- return true;
- }
方法二:
调用
[html] view plaincopy
- setCanceledOnTouchOutside(true);
时间: 2024-10-15 03:38:31