1Window window = dialog.getWindow();
2if(window != null){
3 window.addFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND); // This flag is required to set otherwise the setDimAmount method will not show any effect
4 window.setDimAmount(0.5f); //0 for no dim to 1 for full dim
5}
6