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 回答
一只名叫tom的猫
TA贡献1906条经验 获得超3个赞
大概设置下这个就可以了popupWindow.setOutsideTouchable(true);popupWindow.setFocusable(true);//点击外部,popWindow消失popupWindow.setTouchInterceptor(newOnTouchListener(){@OverridepublicbooleanonTouch(Viewv,MotionEventevent){if(event.getAction()==MotionEvent.ACTION_OUTSIDE){performClick();popupWindow.dismiss();returntrue;}returnfalse;}});
添加回答
举报
0/150
提交
取消
