Flutter-stack層疊樣式
生活随笔
收集整理的這篇文章主要介紹了
Flutter-stack層疊樣式
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
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,),
),
],
),
);
總結
以上是生活随笔為你收集整理的Flutter-stack層疊樣式的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: WSL docker打通容器间通信和追加
- 下一篇: .Net Core,VUE,VS Cod