使用对话框时背景模糊 [英] Background blur while using dialog box

查看:66
本文介绍了使用对话框时背景模糊的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望对话框后面的背景模糊.我使用了这段代码,但是它使整个背景都变黑,而不是模糊

I want the background behind the dialog box to be blurry. I used this code but it black outs the whole background instead of blur

dialog = new Dialog(context,R.style.Theme_Dialog_Translucent);

    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.getWindow().addFlags(WindowManager.LayoutParams.FLAG_BLUR_BEHIND);

推荐答案

我认为您需要在 res-values 文件夹下创建具有自定义样式的 styles.xml ./p>

I think you need to create styles.xml with custom style under res - values folder.

 <style name="Theme.D1NoTitleDim" 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 then use this style with your dialog

dialog = new Dialog(context,style); 

这篇关于使用对话框时背景模糊的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆