Android通过透明度设置背景变暗

变暗

WindowManager.LayoutParams lp=getWindow().getAttributes();
lp.alpha=0.3f;
getWindow().addFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
getWindow().setAttributes(lp);

  

变为原来的样子

WindowManager.LayoutParams lp=getWindow().getAttributes();
lp.alpha=1.0f;                  getWindow().clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
getWindow().setAttributes(lp);

  

posted @ 2018-06-15 10:58  王世桢  阅读(324)  评论(0编辑  收藏  举报