/**
* Stack是層疊布局相當(dāng)于Android中的absolutelayout或者RelativityLayout
* Stack的布局根據(jù)child分為positioned和non-positioned兩種,
* positioned根據(jù)left,top超全,right橘原,bottom來設(shè)置widget的位置似枕,相對于組件左上角
* non-positioned則根據(jù)alignment來設(shè)置widget位置易猫。
* Stack的子widget桶至,先添加的在布局下層歌懒,后添加的在布局上層
Stack({
Key key,
this.alignment = AlignmentDirectional.topStart, //對齊方式啦桌,alignment配合FractionalOffset,占據(jù)的百分比
this.textDirection,
this.fit = StackFit.loose,
this.overflow = Overflow.clip,//超過的部分是否裁剪掉
List<Widget> children = const <Widget>[],
})
*/
Stack(
fit: StackFit.loose,
// alignment: AlignmentDirectional.topCenter,
alignment: FractionalOffset(0.9, 0.5),
children: <Widget>[
Container(
width: 100.0,
height: 100.0,
margin: EdgeInsets.only(right: 20.0,top: 10.0),
color: Color(0xff00ff00),
),
Center(
child: GestureDetector(child: Text("按鈕",
style: TextStyle(
decoration: TextDecoration.lineThrough,
fontSize: 18.0,
fontWeight: FontWeight.bold,
color: Color(0xffff0000),
),),
onTap: () {
print("按鈕");
},
),
),
],
)
Stack(
children: <Widget>[
Container(
width: 200.0,
height: 100.0,
color: Color(0xfff1f1f1),
),
Positioned(
child: GestureDetector(child: Text("按鈕",
style: TextStyle(
decoration: TextDecoration.lineThrough,
fontSize: 18.0,
fontWeight: FontWeight.bold,
color: Color(0xffff0000),
),),
onTap: () {
print("按鈕");
},),
left: 10.0,
top: 20.0,
)
],
),