【BUG笔记】华为手机popwindow背景不变暗的问题

2017-01-04  本文已影响0人  JeahWan
PopupWindow popupWindow = new PopupWindow(this);
WindowManager.LayoutParams lp = getWindow().getAttributes();
//设置显示时的背景透明度0.7f
lp.alpha = 0.7f;
getWindow().addFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
getWindow().setAttributes(lp);
popupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() {    
    @Override
    public void onDismiss() {
          WindowManager.LayoutParams lp = getWindow().getAttributes();
          //dismiss后恢复1f
          lp.alpha = 1f;
          getWindow().clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
          getWindow().setAttributes(lp);    
        }
});

关键代码:

getWindow().addFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
上一篇 下一篇

猜你喜欢

热点阅读