提问人:Saad 提问时间:10/6/2023 最后编辑:user18309290Saad 更新时间:10/7/2023 访问量:54
将卡片中的行居中
To center the row in card
问:
您好,即使
我用中心小部件覆盖行,我也无法使用交叉轴对齐使卡片中的行居中,请帮助...
Card(
elevation: 4.0, // Card elevation
child: Center(
child: Padding(
padding: EdgeInsets.all(16.0), // Padding inside the card
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.center, // Align children in the middle vertically
children: <Widget>[
Column(
children: <Widget>[
Text(
'Following',
style: TextStyle(
fontSize: 18.0,
fontWeight: FontWeight.bold,
),
),
Text(
'5000',
style: TextStyle(
fontSize: 16.0,
),
),
],
),
Column(
children: <Widget>[
Text(
'Following',
style: TextStyle(
fontSize: 18.0,
fontWeight: FontWeight.bold,
),
),
Text(
'5000',
style: TextStyle(
fontSize: 16.0,
),
),
],
),
Column(
children: <Widget>[
Text(
'Following',
style: TextStyle(
fontSize: 18.0,
fontWeight: FontWeight.bold,
),
),
Text(
'5000',
style: TextStyle(
fontSize: 16.0,
),
),
],
),
],
),
答:
0赞
Sumit
10/7/2023
#1
通过在列中添加 mainAxisAlignment: MainAxisAlignment.center,您应该可以获得结果。
Card( elevation: 4.0, // Card elevation
child: Padding( padding: EdgeInsets.all(16.0), // Padding inside the card
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.center, // Align children in the middle vertically
children: <Widget>[
Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text(
'Following',
style: TextStyle(
fontSize: 18.0,
fontWeight: FontWeight.bold,
),
),
Text(
'5000',
style: TextStyle(
fontSize: 16.0,
),
),
],
),
Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text(
'Following',
style: TextStyle(
fontSize: 18.0,
fontWeight: FontWeight.bold,
),
),
Text(
'5000',
style: TextStyle(
fontSize: 16.0,
),
),
],
),
Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text(
'Following',
style: TextStyle(
fontSize: 18.0,
fontWeight: FontWeight.bold,
),
),
Text(
'5000',
style: TextStyle(
fontSize: 16.0,
),
),
],
),
],
)))
上一个:修复整个屏幕的背景屏幕
下一个:h2 标签的标题未垂直居中
评论