class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( title: 'Align组件', home: Scaffold( appBar: AppBar( title: Text('Align组件'), ), //此container默认充满屏幕,但是如果设置了宽高,或者设置了子元素align的widthFactor和heightFactor,则以它为准 body: Container( child: Align( //九种对其方式 // alignment: Alignment.bottomCenter, //对其比例 范围 -1.0~1.0 alignment: Alignment(0.0, 0.0), //设置父容器是自己的多少倍,如果父容器设置了宽高,则这两个参数无效 widthFactor: 3.0, heightFactor: 3.0, child: Container( color: Colors.green, width: 50.0, height: 50.0, child: Text('align'), ), ), )), ); } }
Flutter笔记2:Align-对齐组件
Flutter笔记2:Align-对齐组件的常用属性: