服务器之家:专注于VPS、云服务器配置技术及软件下载分享
分类导航

PHP教程|ASP.NET教程|Java教程|ASP教程|编程技术|正则表达式|C/C++|IOS|C#|Swift|Android|VB|R语言|JavaScript|易语言|vb.net|

服务器之家 - 编程语言 - Android - Flutter布局模型之层叠定位

Flutter布局模型之层叠定位

2022-07-22 11:03何小有 Android

这篇文章主要为大家详细介绍了Flutter布局模型之层叠定位,具有一定的参考价值,感兴趣的小伙伴们可以参考一下

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

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

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
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: <Widget>[
      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(),
  ),
 );
}

Flutter布局模型之层叠定位

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持服务器之家。

原文链接:https://blog.csdn.net/hekaiyou/article/details/53257784

延伸 · 阅读

精彩推荐