[英]How to set the background color for a layout element in flutter
我想設置左/右兩列的背景顏色。
我認為列/行與 Web 開發中的引導程序具有相似的含義/功能。
不過好像什么都比較費勁……
請不要告訴我我必須用 Container 小部件包裝每個 Expanded 並在那里設置顏色...
Container(
margin: EdgeInsets.all(5),
color: Colors.orangeAccent,
child: Column(children: <Widget>[
Row(
children: <Widget>[
Expanded(
flex: 3,
child: Column(
children: <Widget>[
Text("left", textAlign: TextAlign.end,),
],
),
),
Expanded(
flex: 7,
child: Column(
children: <Widget>[
Text(
"right",
textAlign: TextAlign.right,
),
],
)
),
],
),
Row(
children: <Widget>[],
)
]),
),
由於container
具有屬性color
那么您需要用container
包裝column
小部件以更改其顏色:
Expanded(
flex: 3,
child: Container(
color : Colors.black,
child : Column(
children: <Widget>[
Text("left", textAlign: TextAlign.end,),
],
),
)
),
https://api.flutter.dev/flutter/widgets/Container-class.html
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.