AlertDialog alterDialog = new AlertDialog.Builder(context).create();
在show()方法后面设置dimAmount属性,才会生效。进度条也是。
WindowManager.LayoutParams lp=alterDialog .getWindow().getAttributes();
lp.dimAmount=0.0f;
alterDialog .getWindow().setAttributes(lp);
dimAmount在0.0f和1.0f之间,0.0f完全不暗,即背景是可见的 ,1.0f时候,背景全部变黑暗。
PS:如果要达到背景全部变暗的效果,需要设置
alterDialog.getWindow().addFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
,否则,背景无效果。此方法可以用来设置浮动层。
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/18760228/viewspace-763893/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/18760228/viewspace-763893/