gpt4 book ai didi

android - 如何水平对齐不同大小的图标?

转载 作者:行者123 更新时间:2023-12-05 02:25:39 25 4
gpt4 key购买 nike

我正在尝试像这样水平对齐图标,使用 mainAxisAlignment: MainAxisAlignment.spaceEvenlycrossAxisAlignment: CrossAxisAlignment.center

我得到的结果是这样的 result I am getting

但我想得到这样的结果。

desired result

我的代码:

Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
IconButton(onPressed: ()=>{}, icon: Icon(Icons.home_sharp, color: Color(0xFFf1a40a), size: 40,)),
IconButton(onPressed: ()=>{}, icon: Icon(Icons.search_sharp, color: Color(0xFFe7e5d3), size: 40,)),
IconButton(onPressed: ()=>{}, icon: Icon(Icons.add_circle_outlined, color: Color(0xFFfad974), size: 60,)),
IconButton(onPressed: ()=>{}, icon: Icon(Icons.notifications, color: Color(0xFFe7e5d3), size: 40,)),
IconButton(onPressed: ()=>{}, icon: Icon(Icons.people_alt_sharp, color: Color(0xFFe7e5d3), size: 40,)),
],
)

有人可以帮忙吗?

最佳答案

IconButton 上使用 iconSize 而不是 Iconsize

Row(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
IconButton(
iconSize: 40,
onPressed: () => {},
icon: Icon(
Icons.home_sharp,
color: Color(0xFFf1a40a),

)),
IconButton(
iconSize: 40,
onPressed: () => {},
icon: Icon(
Icons.search_sharp,
color: Color(0xFFe7e5d3),

)),
IconButton(
onPressed: () => {},
iconSize: 60,
icon: Icon(
Icons.add_circle_outlined,
color: Color(0xFFfad974),
)),
IconButton(
iconSize: 40,
onPressed: () => {},
icon: Icon(
Icons.notifications,
color: Color(0xFFe7e5d3),

)),
IconButton(
iconSize: 40,
onPressed: () => {},
icon: Icon(
Icons.people_alt_sharp,
color: Color(0xFFe7e5d3),

)),
],
),

enter image description here

关于android - 如何水平对齐不同大小的图标?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/74389413/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com