Stack即層疊布局控件,能夠?qū)⒆涌丶盈B排列。
Stack控件的每一個(gè)子控件都是定位或不定位,定位的子控件是被Positioned控件包裹的。Stack控件本身包含所有不定位的子控件,其根據(jù)alignment定位(默認(rèn)為左上角)。然后根據(jù)定位的子控件的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: <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(), ), );}
以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持VEVB武林網(wǎng)。
新聞熱點(diǎn)
疑難解答
圖片精選
網(wǎng)友關(guān)注