如何在Flutter中对齐按钮中的文字? [英] How to align text in a button in flutter?
本文介绍了如何在Flutter中对齐按钮中的文字?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我只想做最简单的事情:我只想有一个按钮,其文本右对齐.由于某些原因,我无法弄清楚.
I just want to do the most simplest of things: I just want to have a button with the text aligned to the right. For some reason I can't figure this out.
我尝试了textAlign:TextAlign.right,但它仍然在中间.我尝试使用mainAxisAlignment.end在按钮内创建一行,但是没有,仍然在中心.出于某种原因,如果我使用主轴对齐方式,它会起作用.在列而不是行上结束(放在底部而不是右边)
I tried textAlign: TextAlign.right but it's still in the centre. I tried making a row inside the button with mainAxisAlignment.end but nope, still in center. for some reason it works if I use main axis alignment.end on a column instead of a row (puts it at bottom instead of right)
这是我到目前为止所拥有的:
This is what I have so far:
FlatButton(
color: Colors.black,
child: Row(
mainAxisAlignment: MainAxisAlignment.end,
children: <Widget>[
Text(
"M",
textAlign: TextAlign.right,
style: TextStyle(
color: mColor, fontSize: 10.0),
),
],
),
推荐答案
将其放在墨水瓶中
InkWell(
onTap: doSomething,
child: SizedBox(
height: 100,
width: 100,
child: Container(
decoration: BoxDecoration(
border: Border.all(color: Colors.black)),
child: Text(
'hello',
textAlign: TextAlign.right,
),
),
),
),
这篇关于如何在Flutter中对齐按钮中的文字?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文