The method getWindow() is undefined for the type AlertDialog.Builder

前端 未结 2 1603
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-12 03:28

Idea taken from Android: Blurring and dimming background windows from dialog. I\'m having trouble getting the content under my dialog to blur. When calling eula.getWindow(

2条回答
  •  北海茫月
    2021-01-12 04:10

    getWindow() is a method of the dialog class, not of the dialog builder. Your code should rather look like this:

    AlertDialog dlg = eula.show();
    WindowManager.LayoutParams lp = dlg.getWindow().getAttributes();
    lp.dimAmount = 0.0F;
    dlg.getWindow().setAttributes(lp);
    dlg.getWindow().addFlags(WindowManager.LayoutParams.FLAG_BLUR_BEHIND);
    

    Note though that the FLAG_BLUR_BEHIND constant is deprecated now, blurring behind windows is no longer supported. So your code might break in the future.

提交回复
热议问题