Background blur when using a dialog box

I want the background behind the dialog to be blurred. I used this code, but it blacks out the entire background instead of blur

dialog = new Dialog(context,R.style.Theme_Dialog_Translucent);

    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.getWindow().addFlags(WindowManager.LayoutParams.FLAG_BLUR_BEHIND);

      

+3


source to share


2 answers


I think you need to create styles.xml

with custom styling in the folder res - values

.

 <style name="Theme.D1NoTitleDim" parent="android:style/Theme.Translucent">
    <item name="android:windowNoTitle">true</item>
    <item name="android:windowContentOverlay">@null</item>
    <item name="android:backgroundDimEnabled">true</item>
    <item name="android:background">@android:color/transparent</item>        
</style>

      



and then use this style in the dialog

dialog = new Dialog(context,style); 

      

+1


source


Try this:



WindowManager.LayoutParams lp = dialog.getWindow().getAttributes();
lp.dimAmount=0.0f;
dialog.getWindow().setAttributes(lp);
dialog.getWindow().addFlags(WindowManager.LayoutParams.FLAG_BLUR_BEHIND);

      

+1


source







All Articles