flutter组件之Stack
发布日期:2021-10-15 18:54:37 浏览次数:4 分类:技术文章

本文共 1592 字,大约阅读时间需要 5 分钟。

stack组件可以实现定位问题,如果您想以简单的方式重叠多个子级,例如具有一些文本和图像,并用渐变和一个附加在底部的按钮覆盖,则该类很有用。

// SizedBox组件能强制子控件具有特定宽度、高度或两者都有,使子控件设置的宽高失效// width: 100.0,//宽度// height: 100.0,//高度// child:  Container(//   width: 200.0,//   height: 200.0,//   color: Color(0xffff0000),// ),SizedBox(  width: 250,  height: 250,  child: new Stack(    children: 
[ //定位组件 //left: 20.0 //top: 10.0 //right: 10.0 //bottom: 10.0 //width: 10.0 //height: 20.0 //child: new Text() Positioned( top: 100.0, child: Container( color: Colors.blue, child: Text("第一个组件"), ), ), Positioned( top: 200, right: 100, child: Container( color: Colors.yellow, child: Text("第二个组件"), ), ), Positioned( left: 100.0, child: Container( color: Colors.red, child: Text("第三个组件"), ), ), new Container( width: 250, height: 250, color: Colors.white, ), new Container( padding: EdgeInsets.all(5.0), //对齐方式 alignment: Alignment.bottomCenter, decoration: BoxDecoration( //渐变色 gradient: LinearGradient( begin: Alignment.topCenter, end: Alignment.bottomCenter, colors:
[ Colors.black.withAlpha(0), Colors.black12, Colors.black45 ], ), ), child: new Text( "Foreground Text", style: TextStyle(color: Colors.white, fontSize: 20.0), ), ), ], ),)

转载地址:https://blog.csdn.net/shenshulong/article/details/103909141 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:flutter组件之Icon
下一篇:webpack配置文件之配置项mode

发表评论

最新留言

表示我来过!
[***.240.166.169]2024年04月08日 01时02分03秒

关于作者

    喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!

推荐文章