【问题标题】:Reduce top & bottom padding in BottomNavigationBar减少底部导航栏中的顶部和底部填充
【发布时间】: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


【解决方案1】:

要删除 BottomNavigationBar 中的默认空间,请将 selectedFontSize 设置为 0。 它将删除可用于文本的默认空间。 底部导航栏( 选定字体大小:0.0, )

【讨论】:

    猜你喜欢
    • 2022-01-16
    • 2019-11-03
    • 1970-01-01
    • 1970-01-01
    • 2011-11-02
    • 2022-10-18
    • 2017-08-21
    • 2018-04-01
    • 1970-01-01
    相关资源
    最近更新 更多