Flutterで
new Row(children: <Widget>[ new Center( child: new RaisedButton( onPressed: () { }, child: new Text('A'), ), ), new Center( child: new RaisedButton( onPressed: () { }, child: new Text('B'), ), ), ]), ];
と書いても、
となり、Center
が効かない
1つなら真ん中になるのに、2つボタン置くとなぜか左端に寄ってしまう・・・
真ん中に配置したいです。
Centerバージョン
new Center( child: new Row(children: <Widget>[ new RaisedButton( onPressed: () {}, child: new Text('A'), ), new RaisedButton( onPressed: () {}, child: new Text('B'), ), ]), )
RowとmainAxisSizeとmainAxisAlignmentプロパティバージョン
new Row( mainAxisSize: MainAxisSize.max, mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[ new RaisedButton( onPressed: () {}, child: new Text('A'), ), new RaisedButton( onPressed: () {}, child: new Text('B'), ), ], )
上の2つ書いたが、RowとmainAxisSizeとmainAxisAlignmentプロパティバージョンならいけた。
- 作者: Chris Buckett,あんどうやすし,粟納裕貴,勝又雅史,川俣千恵子,植田大貴,井関正也,水野あゆみ
- 出版社/メーカー: KADOKAWA/アスキー・メディアワークス
- 発売日: 2014/03/28
- メディア: 大型本
- この商品を含むブログ (2件) を見る