如何在对话框创建时设置模糊背景

如何在对话框创建时设置模糊背景?

我只找到了DialogFragmentAlertDialog但我想在Activity中设置Dialog

如何创建它或什么是图书馆推荐的?

 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); 

试试这个

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

或试试这个你可以像这样在你的对话框中应用自定义主题

 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); 

现在创建这样的主题

  

并在possition center中检查此AlertDialog的模糊背景