Ale*_*eph 13 text button alignment dart flutter
我只想做最简单的事情:我只想有一个按钮,文本向右对齐。出于某种原因,我无法弄清楚这一点。
我试过 textAlign: TextAlign.right 但它仍然在中心。我尝试使用 mainAxisAlignment.end 在按钮内排成一行,但不,仍然在中心。出于某种原因,如果我在列而不是行上使用主轴对齐,它会起作用(将它放在底部而不是右侧)
这是我到目前为止:
FlatButton(
color: Colors.black,
child: Row(
mainAxisAlignment: MainAxisAlignment.end,
children: <Widget>[
Text(
"M",
textAlign: TextAlign.right,
style: TextStyle(
color: mColor, fontSize: 10.0),
),
],
),
Run Code Online (Sandbox Code Playgroud)
Nik*_*ikh 23
你应该把你的“文本”放在“对齐”中,以左、右、上、下等对齐你的文本。 As-
FlatButton(
color: Colors.blue,
textColor: Colors.white,
padding: EdgeInsets.all(8.0),
splashColor: Colors.blueAccent,
onPressed: () {
/*...*/
},
child: Align(
alignment: Alignment.center,
child: Text(
"Flat",
style: TextStyle(fontSize: 20.0),
textAlign: TextAlign.center
),
))
Run Code Online (Sandbox Code Playgroud)
241*_*116 12
把它放在墨水瓶里
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,
),
),
),
),
Run Code Online (Sandbox Code Playgroud)
对于新的按钮和按钮主题:
TextButton(
onPressed: () {},
child: Text('Cancel'),
style: ButtonStyle(
alignment: Alignment.centerLeft, // <-- had to set alignment
padding: MaterialStateProperty.all<EdgeInsetsGeometry>(
EdgeInsets.zero, // <-- had to set padding to zero
),
),
),
Run Code Online (Sandbox Code Playgroud)
小智 5
这个对我有用
ButtonTheme(
child: FlatButton(
padding: EdgeInsets.all(0),
child: Align(
alignment: Alignment.centerLeft,
child: Text(
"Button text",
style: TextStyle(
color: ThemeColors.primaryDark,
fontWeight: FontWeight.normal,
fontSize: ThemeSizes.normalFont,
),
textAlign: TextAlign.left,
),
),
onPressed: () => _doSomething(),
),
)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
29512 次 |
| 最近记录: |