3

I want the background behind the dialog box to be blurry. I used this code but it black outs the whole 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);
Waynn Lue
  • 11,344
  • 8
  • 51
  • 76
user1169079
  • 3,053
  • 5
  • 42
  • 71

2 Answers2

1

Try it like this instead:

WindowManager.LayoutParams lp = dialog.getWindow().getAttributes();
lp.dimAmount=0.0f;
dialog.getWindow().setAttributes(lp);
dialog.getWindow().addFlags(WindowManager.LayoutParams.FLAG_BLUR_BEHIND);
adneal
  • 30,484
  • 10
  • 122
  • 151
  • still the same ... I guess its because FLAG_BLUR_BEHIND is deprecated .... is there any alternate way? – user1169079 Mar 09 '12 at 10:10
  • Not directly from the SDK, at least that I'm aware of. I suppose you could create a custom background that gives a "blurry" effect and use that. – adneal Mar 09 '12 at 10:13
0

I think you need to create styles.xml with custom style under res - values folder, as described by Chirag Patel here:

<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 with your dialog

dialog = new Dialog(context,style); 
Ryan M
  • 18,333
  • 31
  • 67
  • 74
MKJParekh
  • 34,073
  • 11
  • 87
  • 98