Dismiss PopupWindow on touch outside popup, without using deprecated constructor

前端 未结 3 632
遇见更好的自我
遇见更好的自我 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:17

    What I had to do to get it to work:

    popup.setBackgroundDrawable(new ColorDrawable(ContextCompat.getColor(context, android.R.color.transparent)));
    popup.setOutsideTouchable(true);
    

提交回复
热议问题