dialog 触摸外部事件监听
public class WithTouchDialog extends Dialog {
public WithTouchDialog(@NonNull Context context, int themeResId) {
super(context, themeResId);
init();
}
private void init() {
getWindow().setFlags(WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH, WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL, WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL);
}
@Override
public boolean onTouchEvent(MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_OUTSIDE) {
//外部点击事件监听
}
return true;
}
}
本文标题:dialog 触摸外部事件监听
本文链接:https://www.haomeiwen.com/subject/cqlgnktx.html
网友评论