public class BasePopupWindow extends PopupWindow {
public Context mContext;
public BasePopupWindow (Context context) {
super(context);
this.mContext = context;
//popWindow彈出可以點擊返回鍵消失
this.setFocusable(false);
//設置pop的點擊外面可以消失
this.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
// 設置背景顏色變暗
WindowManager.LayoutParams lp = ((Activity) context).getWindow().getAttributes();
lp.alpha = 0.4f;
((Activity) context).getWindow().setAttributes(lp);
}
@Override
public void dismiss() {
WindowManager.LayoutParams lp1 = ((Activity) mContext).getWindow().getAttributes();
lp1.alpha = 1f;
((Activity) mContext).getWindow().setAttributes(lp1);
super.dismiss();
}
}
基類的popupwindow,帶點擊區域外消失,返回鍵消失
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.