首页 > 解决方案 > android - 更改 AlertDialog 后面的模糊背景颜色

问题描述

我想将黑色透明背景更改为白色透明,尝试更改AppTheme样式但没有成功。

https://i.stack.imgur.com/aYjBc.png

另外我想将黑色模糊背景更改为白色模糊,尝试在AppTheme样式中进行更改。

我也尝试了这个中提到的renderscript、fastblur、xml ,但它只改变了对话框的白色背景

在此处输入图像描述

任何想法如何改变它?提前致谢!

标签: androidkotlindialogandroid-alertdialogandroid-theme

解决方案


使用该样式,您可以更改暗淡而不是模糊。
您可以使用android:backgroundDimAmount属性(范围:)1.0 - 0.0

<style name="ThemeOverlay.App.MaterialAlertDialog" parent="ThemeOverlay.MaterialComponents.MaterialAlertDialog">
    <item name="android:backgroundDimAmount">0.xx</item>
</style>

MaterialAlertDialogBuilder(context, R.style.ThemeOverlay_App_MaterialAlertDialog)
    .setTitle("Title")
    .show()

0.10和_0.90

在此处输入图像描述 在此处输入图像描述


推荐阅读