android - DialogFragment 更改阴影(蒙版)颜色(不是对话框内容)
问题描述
我正在使用 DialogFragment 构建一个对话框,我需要更改阴影(蒙版)的颜色,它是透明的并且始终围绕主对话框内容。其实网上几乎所有的答案都是改对话框颜色,但是我需要把阴影颜色从透明黑改成其他。有没有办法做到这一点?
图片:
解决方案
如果您只想更改背景的 alpha,那么您可以android:backgroundDimAmount
像我一样轻松创建带有属性的样式
<style name="CustomAlertDialogStyle" parent="Theme.AppCompat.Light.Dialog">
<item name="android:backgroundDimAmount">0.5</item>
</style>
值范围为 0-1,然后在 AlertDialog 中将样式传递为
AlertDialog dialog = new AlertDialog.Builder(this, R.style.CustomAlertDialogStyle)
.setTitle("Title").setMessage("message").create();
dialog.show();
但是,如果您也想更改背景颜色,那么您可以尝试@Lee Han Kyeol https://stackoverflow.com/a/29482234/5002610给出的这项工作, 我希望这能解决您的问题。
推荐阅读
- sql-server - SQL Server 查询最后值和平均值
- sql - T-SQL 使用另一个标量变量的值设置标量变量
- asp.net - IIS 返回 400 - 缺少内容错误
- html - 如何正确编写 CSS 属性选择器来提取所有 id 属性?
- sql - SQL:Postgres 语句转换递归连接时出现问题
- mysql - 内查询多列一库
- git - VSTS Git:repo 被 .gitignore 删除了。清理已经执行到 master,但新的 git clone 仍然下载超过 4000 个文件
- python - python pip被virtualenv破坏
- android - pocketsphinx android - 为每个不同的口语返回相同的单词
- node.js - 将管道与 Electron ClientRequest 模块一起使用