I am trying to apply the following in order to help blur the background behind my dialog box which currently has a transparent background: Blur Background Behind AlertDialog
Only issue is, when the following section of code is applied inside the launch of my dialog box following an OnClick Method in my MainActivity.java:
‘Bitmap map=takeScreenShot(BlurImageView.this);
‘Bitmap fast=fastblur(map, 10);’
There is a red line under ‘map, 10’ with the error: ‘fastblur(android.graphics.Bitmap, float, int)’ in ‘anonymous class’ cannot be applied to ‘(android.graphics.Bitmap, int)’
Does anybody know what I might need do to eliminate this error please? Everything else seems to be fine, bar for that small snippet of code.
I can provide the rest of my MainActivity code if required? Unless anybody knows of a better way to blur the background under a dialog box in 2022?
Many thanks.
2
Answers
I have managed to seek and apply a solution now, so thank you for your help! It relies on the method whereby a screenshot is taken of the Activity before the Dialog Box is opened, followed by a blurring of the screenshot image and placement of it behind the Dialog Box. It's not always the quickest on the Emulator (it is yet to be trialled on my own Smartphone, for instance), but it does look good and the level of blurring effect can be tailored to specific needs. I'm fairly sure the solution is posted on a separate thread on this site, for those interested.
i have done this by using framelayout.
Here is the XML part for this.
And here is the Code part where i have set the background of the dialog transparent.