【发布时间】:2020-04-19 13:30:55
【问题描述】:
我想减少 BottomNavigationBar 的顶部和底部填充,但我想保持相同的图标高度和栏高度为 50 像素:
bottomNavigationBar: SizedBox(
height: 50,
child: BottomNavigationBar(
showSelectedLabels: false,
showUnselectedLabels: false,
type: BottomNavigationBarType.fixed,
elevation: 5.0,
currentIndex: 0,
items: buildBottomBarItems(),
),
)
底栏项目的构建方法:
List<BottomNavigationBarItem> buildBottomBarItems() {
List<BottomNavigationBarItem> _bottomBarItems = List();
List<String> _iconNames = ["home", "search", "plus", "heart"];
for (var i = 0; i < _iconNames.length; ++i) {
_bottomBarItems.add(
BottomNavigationBarItem(
icon: Container(
child: new Image.asset('assets/' + _iconNames[i] + '.png', width: 24, height: 24)
),
title: Text('')
)
);
}
}
(在本例中溢出 4.0 像素)。谢谢
【问题讨论】:
-
你解决了吗?
标签: flutter flutter-layout padding navigationbar