/*
Flutter 页面布局 Stack层叠组件:
Stack与Align Stack与Positioned实现定位布局:
Flutter Stack组件:
Stack表示堆得意思,我们可以用Stack或者Stack结合Align或者Stack结合Positiond来实现页面的定位布局:
alignent 配置所有子元素的显示位置。
children 子组件 Flutter Stack Align
Stack组件中结合Align组件可以控制每个子元素的显示位置。 */

Stack与Align实现定位布局:

效果图:

main.dart

import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
} class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
// TODO: implement build
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: Text('Padding Row Column Expanded'),
),
body: HomeContent(),
),
);
}
} class HomeContent extends StatelessWidget {
@override
Widget build(BuildContext context) {
//Stack结合align实现布局:
return Center(
child: Container(
width: 300.0,
height: 400.0,
color: Colors.red,
child: Stack(
children: <Widget>[
Align(
alignment: Alignment.topLeft,
child: Icon(Icons.home, color: Colors.white,size: ),
),
Align(
alignment: Alignment.center,
child: Icon(Icons.search, color: Colors.white,size: ),
),
Align(
alignment: Alignment.bottomRight,
child: Icon(Icons.select_all, color: Colors.white,size: ),
),
],
),
),
);
}
}

Stack与Positioned

效果图:

main.dart

import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
} class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
// TODO: implement build
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: Text('Padding Row Column Expanded'),
),
body: HomeContent(),
),
);
}
} class HomeContent extends StatelessWidget {
@override
Widget build(BuildContext context) {
//Stack结合align实现布局:
return Center(
child: Container(
width: 300.0,
height: 400.0,
color: Colors.red,
child: Stack(
children: <Widget>[
Positioned(
top: ,
right: ,
child: Icon(Icons.home, color: Colors.white,size: ),
),
Positioned(
top: ,
left: ,
child: Icon(Icons.search, color: Colors.white,size: ),
),
Positioned(
bottom: ,
right: ,
child: Icon(Icons.select_all, color: Colors.white,size: ),
),
], ),
),
);
}
}

最新文章

  1. 关于控件的Invoke(...)方法和BeginInvoke(...)方法的区别
  2. ubuntu下面mysql,通过载入txt文件初始化数据表
  3. UDP信息接收与发送
  4. Azure开发者任务之四:在Azure SDK 1.3中挂载调试器的错误
  5. Swift与Objective-c 混编CocoaPods 引入第三方库遇到的问题 (一)
  6. 图片剪裁上传插件 - cropper
  7. svn提交时强制注释
  8. php防止sql注入函数
  9. hive函数总结-字符串函数
  10. linux C函数之access函数的用法
  11. C语言之逻辑运算符
  12. mysql中加入海量数据
  13. 晨读笔记:CSS3选择器之属性选择器
  14. LeetCode - Cut Off Trees for Golf Event
  15. 机器学习实战之朴素贝叶斯进行文档分类(Python 代码版)
  16. Android MediaPlayer接口及状态迁移
  17. Confluence 6 快捷键
  18. ORACLE RAC节点意外重启Node Eviction诊断流程图(11.2+)
  19. Linux学习笔记:cat、tac、more、less、head、tail查看文件内容
  20. laravel中,提交表单后给出提示例如添加成功,添加失败等等

热门文章

  1. Ubuntu系统---nvidia驱动下载之问题
  2. Ubuntu系统---系统驱动丢失、Kernel内核卸载、禁止更新
  3. 多线程 multiprocessing 的几个小例子
  4. Python基础之异常
  5. sklearn逻辑回归实战
  6. python_网络编程socket(TCP)
  7. dubbo注册ip混乱的问题
  8. POJ-1661-Help Jimmy(DP, 递推)
  9. [Google Guava] 7-原生类型
  10. RedisTemplate 中 opsForHash()使用 (没有测试过,copy的)