Flutter:尝试使某列在列中居中,但仍保持左对齐 [英] Flutter: Trying to bottom-center an item in a Column, but it keeps left-aligning
本文介绍了Flutter:尝试使某列在列中居中,但仍保持左对齐的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图使小部件在列底部居中居中,但始终保持与左侧对齐。
I'm trying to bottom-center a widget at the bottom of a Column, but it keeps aligning to the left.
return new Column(
new Stack(
new Positioned(
bottom: 0.0,
new Center(
new Container(),
),
),
),
);
已定位的存在会迫使容器向左移动而不是居中。但是,删除已定位将容器放在中间居中。
The existence of the Positioned forces the Container to the left, instead of centering. Removing the Positioned, however, puts the Container in the middle-center.
推荐答案
对齐要走的路是只有一个孩子。
Align is the way to go is you have only one child.
如果有更多内容,请考虑执行以下操作:
If you have more, consider doing something like this :
return new Column(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.end,
children: <Widget>[
//your elements here
],
);
这篇关于Flutter:尝试使某列在列中居中,但仍保持左对齐的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文