到底是要变暗还是不变暗啊。
我的方法是这样的
public class CustomDialog extends Dialog {
public CustomDialog(Context context, int themeResId) {
super(context, themeResId);
WindowManager.LayoutParams l = getWindow().getAttributes();
//0.0f完全不暗,即背景是可见的 ,1.0f时候,背景全部变黑暗。
l.dimAmount = 0.85f;
//设置背景全部变暗的效果
getWindow().addFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
getWindow().setAttributes(l);
}
}