Flutter-stack層疊樣式
2024-09-05 18:22:16
alignment調整佈局
var stack = new Stack(
alignment: Alignment.center,//元素居中
//alignment: Alignment (1,1),//xy座標,可使用小數點
children: <Widget>[
//按順序疊放
Container(
height: 300,
width: 300,
color: Colors.red,
),
Text('文字')
],
);
多個元素定位
Align
var stack = new Container(
height: 400,
width: 300,
color: Colors.blueAccent,
child: Stack(
children: <Widget>[
Align(
//alignment:Alignment.topLeft,
alignment:Alignment(1,2),
child: Icon(Icons.access_alarm,size: 30,color: Colors.red,),
),
Align(
alignment:Alignment.center,
child: Icon(Icons.access_alarm,size: 30,color: Colors.red,),
),
Align(
alignment:Alignment.bottomLeft,
child: Icon(Icons.access_alarm,size: 30,color: Colors.red,),
),
],
),
);
Positioned
var stack = new Container(
height: 400,
width: 300,
color: Colors.blueAccent,
child: Stack(
children: <Widget>[
Positioned(
top:1,
left: 1,
right: 1,
bottom: 1,
child: Icon(Icons.access_alarm,size: 30,color: Colors.red,),
),
Positioned(
top:1,
left: 1,
child: Icon(Icons.access_alarm,size: 30,color: Colors.red,),
),
Positioned(
right: 1,
bottom: 1,
child: Icon(Icons.access_alarm,size: 30,color: Colors.red,),
),
],
),
);
最新文章
- d-规则
- 初学者--bootstrap(三)下载与安装----在路上(7)
- SSH协议及其应用
- MySQL日常应用和操作记录
- BIP_开发案例08_BI Publisher图表示例 饼状图/直方图/折线图(案例)
- Swift - 本地消息的推送通知(附样例)
- html5实现渐变效果
- Redis源码研究--字符串
- (转)在Repeater中嵌套使用Repeater
- 开始我的.NET的学习旅程
- MyBatis之级联——一对一关系
- java 运行时常量、编译时常量、静态块执行顺序
- ios中pch文件的创建与配置
- Android设计模式总结
- toLatin1 qt
- flask 虚拟换将安装
- py文件的运行
- OpenLdap 对接内部系统(Gitlab+Wiki+Jumpserver+Openvpn)配置
- 《统计学习方法》笔记(3):k近邻
- Codeforces483B. Friends and Presents(二分+容斥原理)