popup window outside click set to false [setOutsideTouchable(false)] does not work

前端 未结 3 526
无人及你
无人及你 2021-01-14 23:09

//create layoutinflator try {

        LayoutInflater inflator = LayoutInflater.from(this);

//create view

        fi         


        
相关标签:
3条回答
  • 2021-01-14 23:29

    Try the below code. Its working for me

    popUp.setOutsideTouchable(false);
    popUp.setFocusable(true);
    popUp.showAtLocation(this.layout, Gravity.CENTER, 0, 0);
    
    0 讨论(0)
  • 2021-01-14 23:31

    Try this:

    pw.setTouchable(true);    
    pw.setFocusable(false);    
    pw.setOutsideTouchable(false);  
    

    When window touchable is true, focusable is false, setOutsideTouchable() works.

    If setOutsideTouchable(true), touch outside of popupwindow will dismiss, otherwise the outside of popupwindows still can be touchable without dismiss.

    0 讨论(0)
  • 2021-01-14 23:38

    To dismiss the popup window just add the following line of code

      popupWindow.setBackgroundDrawable(new ColorDrawable());
    

    It worked for me and i am sure this is what you want.

    0 讨论(0)
提交回复
热议问题