PopupWindow window=new PopupWindow(popView, ViewGroup.LayoutParams.MATCH_PARENT,DensityUtils.dip2px(context,300),true);
window.showAsDropDown(filter);
darkenBackground(0.2f);
window.setOnDismissListener(new PopupWindow.OnDismissListener() {
// 设置popwindow消失的监听将activity的颜色恢复
@Override
public void onDismiss() {
darkenBackground(1f);
}
window.showAsDropDown(filter);
darkenBackground(0.2f);
window.setOnDismissListener(new PopupWindow.OnDismissListener() {
// 设置popwindow消失的监听将activity的颜色恢复
@Override
public void onDismiss() {
darkenBackground(1f);
}
});
// * 改变activity背景颜色
// */
private void darkenBackground(Float bgcolor){
WindowManager.LayoutParams lp = context.getWindow().getAttributes();
lp.alpha = bgcolor;
context.getWindow().addFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
context.getWindow().setAttributes(lp);
}
// */
private void darkenBackground(Float bgcolor){
WindowManager.LayoutParams lp = context.getWindow().getAttributes();
lp.alpha = bgcolor;
context.getWindow().addFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
context.getWindow().setAttributes(lp);
}