Mus*_*man 10 flutter flutter-layout
尝试将容器与文本视图子对齐,它有一个行父对象在另一列内,尝试了Stack Overflow的多个解决方案,但没有用.
码
///Transactions Heading
new Column(
children: <Widget>[
new Row(
children: <Widget>[
new Container(
alignment: Alignment.centerLeft,
margin: new EdgeInsets.only(top: 20.0, left: 10.0),
child: new Text(
"Transactions",
style: new TextStyle(
color: primaryTextColor,
fontSize: 25.0,
fontWeight: FontWeight.w700,
letterSpacing: 0.1,
),
),
),
new Container(
margin: new EdgeInsets.only(top: 25.0),
child: new Text(
currentGoalTransactions.length.toString() + " items",
style: new TextStyle(
color: darkHeadingsTextColor, fontSize: 15.0),
),
),
],
),
]);
Run Code Online (Sandbox Code Playgroud)
想要将2项文本对齐到右侧
Vin*_*mar 27
mainAxisAlignment在Row小部件中使用该属性.
new Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
...
)
Run Code Online (Sandbox Code Playgroud)
使用Spacer它将获得剩余空间并平均分配小部件
Row(
children: <Widget>[
Text("Text 1", style: TextStyle(fontSize: 20),),
Spacer(),
Text("Text 2", style: TextStyle(fontSize: 20),),
Spacer(),
Text("Text 3", style: TextStyle(fontSize: 20),),
],
),
Run Code Online (Sandbox Code Playgroud)
输出:
| 归档时间: |
|
| 查看次数: |
15442 次 |
| 最近记录: |