user-interface - 如何对齐脚手架上的背景图像?
问题描述
我有一个页面,我想在我的脚手架上的轮子周围设置这个金色边框。这是我的代码:
Widget spinningWheel(context) {
double realWidth = MediaQuery.of(context).size.width;
return Container(
decoration: BoxDecoration(color: Colors.transparent),
//color: Theme.of(context).primaryColor.withAlpha(180),
child: Align(
alignment: Alignment.topCenter,
child: Spinwheel(
shouldDrawCenterPiece: true,
wheelPaint: Paint()..color = Colors.red,
sectorDividerPaint: Paint()..color = Colors.black,
centerPiecePaint: Paint()..color = Colors.black,
items: items,
size: realWidth * 0.9,
onChanged: (val) {
if (this.mounted) setState(() {});
},
select: select,
shouldDrawDividers: true,
wheelOrientation: pi / 8,
autoPlay: false,
hideOthers: false,
shouldDrawBorder: false,
shouldHighlight: false,
),
),
);
}
这是我正在使用的依赖项:https ://pub.dev/packages/flutter_spinwheel
解决方案
尝试 Stack Widget 并相应地设置对齐这是演示并确保您使用的是透明背景图像:
@override
Widget build(BuildContext context) {
Size size = MediaQuery.of(context).size;
return Scaffold(
body: Stack(
children: <Widget>[
Align(
alignment: Alignment.topCenter,
child: new Image.asset(
'assets/yellow_circle.jpg',
width: size.width,
height: size.height/2,
fit: BoxFit.fill,
),
),
Align(
alignment: Alignment.topCenter,
child: new Image.asset(
'assets/red_circle.png',
width: size.width,
height: size.height/2,
fit: BoxFit.fill,
),
),
],
),
);
}
}
推荐阅读
- python - 发生 True 时循环不会中断
- javascript - google lighthouse 如何计算 javascript 评估时间以及为什么它在不同环境中的相同脚本差异很大
- javascript - Vue JS - 反应式电话号码格式
- javascript - Javascript If else 只执行 else 语句
- r - 每个字符上的数据帧单独行
- grep - 在 WSL 中的某些 grep 命令没有得到任何输出
- post - 使用带有 fetch 的 RPC 端点,得到 400 错误
- javascript - 如何制作电子表格的副本并将其保存到特定文件夹,然后打开副本进行编辑
- python - Seaborn lineplot 使用一个分组变量分别绘制所有条目(线)以进行着色
- batch-file - 结合两行cmd并添加“if”条件,可以吗?