Dismiss PopupWindow on touch outside popup, without using deprecated constructor

前端 未结 3 652
遇见更好的自我
遇见更好的自我 2021-02-13 04:55

I have a PopupWindow and I wanted it to dismiss when the user touches outside, so I looked into and found out that I had to use popup.setBackgroundDrawable(new BitmapDrawa

3条回答
  •  一生所求
    2021-02-13 05:21

    Hmm setBackgroundDrawable don't dissmiss popup window. I think that default behavior of popup window is to dismiss on touching outside but you may add onDismiss listener like that

    popup.setOnDismissListener(new PopupWindow.OnDismissListener() {
    
        @Override
        public void onDismiss() {
            popup.dismiss();
            // end may TODO anything else                   
        }
    });
    

提交回复
热议问题