View PopupView = LayoutInflater.from(this).inflate(R.layout.dialog_custom, null);
PopupWindow CanpopupWindow = new PopupWindow(PopupView, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
CanpopupWindow.setFocusable(true);//聚焦/解决点击view重新打开popwindow的问题
CanpopupWindow.setOutsideTouchable(true);//允许点击PopupWindow外部
CanpopupWindow.setBackgroundDrawable(null);
CanpopupWindow.setBackgroundDrawable(new ColorDrawable());//不设置背景,下面消失的代码可能不起作用
CanpopupWindow.showAtLocation(Btnlayout, Gravity.CENTER, 0, -100);//设置显示位置
网友评论