美文网首页
关于popupWindow点击外层不能消失的问题

关于popupWindow点击外层不能消失的问题

作者: Jannonx | 来源:发表于2017-12-14 17:30 被阅读589次

直接上popupwindow的代码

    if (hotWordsList != null && hotWordsList.size() >= 1) {
        searchAText.setText(hotWordsList.get(0));
        mPopup_search_hot_word_layout = LayoutInflater.from(this).inflate(R.layout.popup_search_hotword_layout, null);
        mHotWordPopWindow = new PopupWindow(mPopup_search_hot_word_layout,
                LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT, true);
    }
    ListView popListView = (ListView) mPopup_search_hot_word_layout.findViewById(R.id.popup_search_hot_word_list);
    HotWordPopupAdapter hotWordPopupAdapter = new HotWordPopupAdapter(SttmFristActivity.this, hotWordsList);
    popListView.setAdapter(hotWordPopupAdapter);
    mHotWordPopWindow.setTouchable(true); // 设置popupwindow可点击
    mHotWordPopWindow.setOutsideTouchable(true); // 设置popupwindow外部可点击

点击外部无法消失,废话
其实这是个小坑,popupwindow要设置背景才能点击其他地方关闭,背景随你设置成什么颜色

 mHotWordPopWindow.setBackgroundDrawable(new BitmapDrawable());

相关文章

网友评论

      本文标题:关于popupWindow点击外层不能消失的问题

      本文链接:https://www.haomeiwen.com/subject/hbokwxtx.html