美文网首页
dialog 触摸外部事件监听

dialog 触摸外部事件监听

作者: crossroads | 来源:发表于2020-12-26 14:40 被阅读0次
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