美文网首页
【BUG笔记】华为手机popwindow背景不变暗的问题

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

作者: JeahWan | 来源:发表于2017-01-04 17:49 被阅读0次
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);

相关文章

网友评论

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

      本文链接:https://www.haomeiwen.com/subject/etfavttx.html