【发布时间】:2021-04-19 05:16:38
【问题描述】:
我正在使用图像作为颤动浮动操作按钮的子项。我不需要任何背景颜色。 而且我需要使图像尺寸更大。我怎样才能做到这一点?请帮忙。
【问题讨论】:
标签: android image flutter floating-action-button
我正在使用图像作为颤动浮动操作按钮的子项。我不需要任何背景颜色。 而且我需要使图像尺寸更大。我怎样才能做到这一点?请帮忙。
【问题讨论】:
标签: android image flutter floating-action-button
Colors.transparent
将从任何接受颜色参数的小部件中删除颜色。请在您的 FloatingActionButton 中使用它,如下所示:
FloatingActionButton(
elevation: 0.0,
child: new Icon(Icons.check),
backgroundColor: Colors.transparent,
onPressed: (){}
)
【讨论】:
我认为对于您的情况,您也可以尝试这样的解决方法,
floatingActionButton: GestureDetector(
onTap: () {
// Do Something
},
child: Container(
decoration: BoxDecoration(
image: DecorationImage(
image: NetworkImage("https://www.dartpad.dev/dart-192.png")),
borderRadius: BorderRadius.circular(0.50),
),
width: 50.0,
height: 50.0,
),
),
使用height 和width 值来获得所需的结果。您还可以将boxShadow 添加到Container 以看起来像实际的FAB。
参考:https://api.flutter.dev/flutter/painting/BoxDecoration-class.html
以及从资产中包含您的图像,请参阅https://api.flutter.dev/flutter/painting/DecorationImage-class.html
希望这适合你的情况!
【讨论】:
AssetImage。参考:api.flutter.dev/flutter/painting/AssetImage-class.html
只需这样做:
FloatingActionButton(
backgroundColor: Colors.transparent,
)
【讨论】: