为了账号安全,请及时绑定邮箱和手机立即绑定

请问这样弹出PopupWindow,怎么可以弹出时让外部控件不可点击?网上查了好多方法都不行.

请问这样弹出PopupWindow,怎么可以弹出时让外部控件不可点击?网上查了好多方法都不行.

皈依舞 2019-05-22 21:14:34
privatevoidshowLoading(){//TODO:bug:目前弹出window时可以点击外部控件ViewtypeWindow=LayoutInflater.from(mContext).inflate(R.layout.loading,null);rlLoading=typeWindow.findViewById(R.id.rl_loading);mPopupWindow=newPopupWindow(typeWindow,ViewGroup.LayoutParams.WRAP_CONTENT,ViewGroup.LayoutParams.WRAP_CONTENT);mPopupWindow.setOutsideTouchable(false);mPopupWindow.setFocusable(false);//mPopupWindow.setBackgroundDrawable(newColorDrawable(0x00000000));mPopupWindow.showAtLocation(view.findViewById(R.id.rl_login),Gravity.CENTER,0,0);//popupwindow弹出的位置WindowManager.LayoutParamslpType=mWindow.getAttributes();//设置背景颜色变暗lpType.alpha=0.7f;mWindow.setAttributes(lpType);mPopupWindow.setOnDismissListener(newPopupWindow.OnDismissListener(){@OverridepublicvoidonDismiss(){WindowManager.LayoutParamslp=mWindow.getAttributes();lp.alpha=1f;mWindow.setAttributes(lp);}});}
查看完整描述

2 回答

?
慕娘9325324

TA贡献1783条经验 获得超5个赞

我这里的做法是,设置Pop全屏添加半透明背景覆盖Activity/Fragment视图给pop背景添加点击事件,点击事件不做任何事情
                            
查看完整回答
反对 回复 2019-05-22
?
一只名叫tom的猫

TA贡献1906条经验 获得超3个赞

大概设置下这个就可以了
popupWindow.setOutsideTouchable(true);
popupWindow.setFocusable(true);
//点击外部,popWindow消失
popupWindow.setTouchInterceptor(newOnTouchListener(){
@Override
publicbooleanonTouch(Viewv,MotionEventevent){
if(event.getAction()==MotionEvent.ACTION_OUTSIDE){
performClick();
popupWindow.dismiss();
returntrue;
}
returnfalse;
}
});
                            
查看完整回答
反对 回复 2019-05-22
  • 2 回答
  • 0 关注
  • 2109 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号