【发布时间】:2019-04-18 13:50:18
【问题描述】:
我想在我的容器中居中放置一个图像和按钮 .. 所以我使用了 align 并将其设置为 bottomCenter .. 但它不起作用!
这是我的容器:经过一些更新
return new Container(
height: MediaQuery.of(context).size.height,
width: MediaQuery.of(context).size.width,
decoration: new BoxDecoration(
image: new DecorationImage(
image: new AssetImage(
globals.uiLabels['wthimg' + (index + 1).toString()]
[globals.currentLang]),
fit: BoxFit.cover,
),
),
child: Stack(
children: <Widget>[
Column(
mainAxisSize: MainAxisSize.max,
children: <Widget>[
new Padding(
padding: EdgeInsets.only(
top: MediaQuery.of(context).size.height/2 +100),
child: new Column(
children: <Widget>[
new Text(
globals.uiLabels[
'wthtitle' + (index + 1).toString()]
[globals.currentLang],
style: TextStyle(
fontSize: 18.0,
color: Colors.white,
fontWeight: ui.FontWeight.bold),
),],),),
new Padding(
padding:
EdgeInsets.only(top: 20, right: 10, left: 10),
child: new Column(
children: <Widget>[
new Text(
globals.uiLabels[
'wthdesc' + (index + 1).toString()]
[globals.currentLang],
softWrap: true,
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 16.0,
color: Colors.white,
),),],),),],),
Align(
child: Padding(
padding: EdgeInsets.only(top: 10),
child: Column(
children: <Widget>[
Padding(
padding: EdgeInsets.only(top: 20.0),
child: new Image(
image: AssetImage(globals.uiLabels[
'wthpager' +
(index + 1).toString()]
[globals.currentLang]),
width: 70,
),
),
new RaisedButton(
shape: new RoundedRectangleBorder(
borderRadius:
new BorderRadius.circular(5.0)),
child: new Text(
globals.uiLabels['skip']
[globals.currentLang],
style: new TextStyle(
color: Colors.white, fontSize: 18.0),
),
color: Color(0x0049C275),
elevation: 0.0,
onPressed: () {
navigationPage();
},),],),),
alignment: Alignment.bottomCenter,
)],),);
我想要底部居中..是对齐小部件内的部分...
尝试了对齐、堆栈和行..但没有一个成功...
如何解决这个问题?并使其始终以底部为中心...
跳过它上面的图像..我希望它们位于页面的底部中心..但现在它们位于顶部中心
【问题讨论】:
-
因为
Column。RaisedButton在Column内部居中,但Column如果不适合或居中在Container内部 -
使用堆栈小部件并在其中使用对齐小部件。
-
@AndreyTurkovsky 那么我该如何解决呢?
-
@ibhavikmakwana 试图这样做,但也没有用..
-
@pskink 得知 debugPaintSizeEnabled 未定义 ...