How to set Blur background when dialog create

我是研究僧i 提交于 2019-12-03 20:54:40

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!