flutter - 不透明的不透明问题扑朔迷离
问题描述
我无法弄清楚如何实现不透明度,以便它不会影响其中的文本......我只是希望背景完全消失并留下文本。我不能把它留白,因为应用程序本身有背景
而且我也找不到有关如何在下面创建一条跨越屏幕的线以将瓷砖彼此分开的文档
这是我的清单
? new ListView.builder(
itemCount: controlHeadings.length,
itemBuilder: (BuildContext context, int index) {
return new Opacity(
opacity: 0.9,
child: new Card(
color: Theme.CompanyColors.coolGrey,
elevation: 2.0,
child: new ListTile(
leading: new Text(
"${controlHeadings[index]['id']}",
style: new TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold,
),
),
title: new Text(
"${controlHeadings[index]['title']}",
style: new TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold,
fontSize: 15.0,
),
),
解决方案
考虑Opacity
作为过滤器。它完全影响它的孩子。考虑到这一点,您所要求的是“不可能的”。
相反,您应该提取需要绕过的内容,以Opacity
确保它不是Opacity
. 您可以通过使用来实现这一点Stack
:
Stack(
children: [
Positioned.fill(
child: Opacity(
opacity: .9,
child: Card(color: Colors.red),
),
),
Text("Not affected"),
],
)
或者,您可以更改Card
usingwithOpacity
方法的背景颜色:
Card(
color: Colors.red.withOpacity(.9),
child: Text("foo"),
)
推荐阅读
- php - Yii2 用 Like 查询
- php - 如何将 PHP 文件版本 5.6 迁移到 7.2
- angular - Angular 4 -> 6 代码错误“没有将“exportAs”设置为“ngModel”的指令”
- prolog - 如何摆脱单例变量错误?
- mysql - 替换 utf8mb4_unicode_ci 上的特定字符 MySQL 搜索
- python - Python 脚本未编写最终条目
- node.js - 作为邮递员的请求发送查询参数
- mysql - 是否有 MySQL 服务器支持的权限的可查询表?
- python - 无法将整数连接到 xpath 并且无法找到它
- java - 摆脱或复制私有静态