1.外部不可点击,在Activity中重写dispatchTouchEvent,如下
@Override
public boolean dispatchTouchEvent(MotionEvent event) {
//hasShow弹窗调用后为true,PopupWindow.setOnDismissListener里面设为false
if (hasShow) return false;
return super.dispatchTouchEvent(event);
}
2.半透明效果,然后在PopupWindow.setOnDismissListener里面充值为1f即可
//this是当前的Activity
WindowManager.LayoutParams lp = this.getWindow().getAttributes();
lp.alpha = 0.7f;//需要显示的半透明度
this.getWindow().setAttributes(lp);
//下面这行是重点,否则在安卓10以后半透明无效
this.getWindow().addFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
网友评论