Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set Blur background when dialog create

How to set Blur background when dialog create?

I found DialogFragment only and AlertDialog but I want to set in Dialogin activity

How to create it or What's library recommend?

final Dialog dialog = new Dialog(this);
        dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
        Window window = dialog.getWindow();
        window.setBackgroundDrawableResource(android.R.color.transparent);
        window.setLayout(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
        dialog.setContentView(R.layout.register_policy_dialog);
like image 213
ARR.s Avatar asked Aug 21 '17 16:08

ARR.s


People also ask

How do you blur the background of a dialog box in flutter?

In flutter, The dimming effect behind the dialog and bottom sheets is done using a class named 'ModalBarrier'. So what you can do is just modify the code where it dims the background. child: color == null ? null : BackdropFilter( filter: new ImageFilter.


1 Answers

try this

dialog.getWindow().addFlags(WindowManager.LayoutParams.FLAG_BLUR_BEHIND); 

or try this you can apply a custom theme to your dialog like this

Dialog customDialog= new Dialog(MainActivity.this,R.style.mytheme); 
Window window = customDialog.getWindow();
window.setLayout(WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.WRAP_CONTENT);
window.setGravity(Gravity.CENTER);

now create the theme like this

<style name="mytheme" 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 also check this AlertDialog with Blur background in possition center

like image 125
AskNilesh Avatar answered Sep 21 '22 17:09

AskNilesh