设置了backgroundColor为Colors.transparent,阴影也设置为0之后,居然还有一层白色不明view,有大神知道怎么去的吗?
还需给Scaffold设置透明背景才能去除白色
Scaffold(
backgroundColor: Colors.transparent,
appBar: AppBar(
backgroundColor: Colors.transparent,
...
)
...
不是你的appBar没有变透明,而是它已经透明了,但是Scaffold是有背景色的。Scaffold默认背景色就是画布颜色,dark主题是Colors.grey[850],light主题是Colors.grey[50]。你可以给Scaffold加一个backgroundColor,会发现appBar背景色也会跟着变化。
Scaffold(
appBar: AppBar(
title: const Text('Next page'),
backgroundColor: Colors.transparent,
elevation: 0,
)
Scaffold(
appBar: AppBar(
elevation: 0,
backgroundColor: Colors.transparent,
),
)
或者
Scaffold(
appBar: AppBar(
shadowColor: Colors.transparent,
backgroundColor: Colors.transparent,
),
)
将elevation设置为0,elevation默认是4
或者
backgroundColor设置为透明,backgroundColor默认为FF000000
1 回答814 阅读✓ 已解决
4 回答1.1k 阅读
1 回答749 阅读✓ 已解决
2 回答934 阅读
1 回答678 阅读✓ 已解决
1 回答1.3k 阅读
2 回答722 阅读
elevation必须设置成0 才有效!