栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 移动开发 > Android

Flutter布局模型之层叠定位

Android 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

Flutter布局模型之层叠定位

Stack即层叠布局控件,能够将子控件层叠排列。

Stack控件的每一个子控件都是定位或不定位,定位的子控件是被Positioned控件包裹的。Stack控件本身包含所有不定位的子控件,其根据alignment定位(默认为左上角)。然后根据定位的子控件的top、right、bottom和left属性将它们放置在Stack控件上。

import 'package:flutter/material.dart';
class LayoutDemo extends StatelessWidget {
 @override
 Widget build(BuildContext context) {
  return new Scaffold(
   appBar: new AppBar(
    title: new Text('层叠定位布局'),
   ),
   body:new Center(
    child: new Stack(
     children: [
      new Image.network('http://img2.cxtuku.com/00/13/12/s97783873391.jpg'),
      new Positioned(
left: 35.0,
right: 35.0,
top: 45.0,
child: new Text(
 'Whatever is worth doing is worth doing well. ๑•ิ.•ั๑',
 style: new TextStyle(
  fontSize: 20.0,
  fontFamily: 'serif',
 ),
),
      ),
     ]
    ),
   ),
  );
 }
}
void main() {
 runApp(
  new MaterialApp(
   title: 'Flutter教程',
   home: new LayoutDemo(),
  ),
 );
}

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持考高分网。

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/155570.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号