【问题标题】:Four icons added in the BottomNavigationBarItem is not workingBottomNavigationBarItem 中添加的四个图标不起作用
【发布时间】:2018-07-27 12:12:23
【问题描述】:

我是 Flutter 的新手,当我尝试添加四个图标时,我创建了一个底部导航栏。图标颜色变为白色。我应该如何实现这一点任何人都可以建议我。下面是我的代码。任何帮助将不胜感激。

 bottomNavigationBar: new BottomNavigationBar(items: [
    new BottomNavigationBarItem(icon: new Icon(Icons.add), title: new Text("Text")),
    new BottomNavigationBarItem(icon: new Icon(Icons.person), title: new Text("Contact")),
    new BottomNavigationBarItem(icon: new Icon(Icons.accessibility), title: new Text("Acess")),
    new BottomNavigationBarItem(icon: new Icon(Icons.account_balance), title: new Text("Balance"))
  ]),

【问题讨论】:

    标签: dart flutter


    【解决方案1】:

    当元素超过3个时,需要显式设置type: BottomNavigationBarType.fixed,

    bottomNavigationBar: new BottomNavigationBar(
        type: BottomNavigationBarType.fixed,
        items: [
        new BottomNavigationBarItem(icon: new Icon(Icons.add), title: new Text("Text")),
        new BottomNavigationBarItem(icon: new Icon(Icons.person), title: new Text("Contact")),
        new BottomNavigationBarItem(icon: new Icon(Icons.accessibility), title: new Text("Acess")),
        new BottomNavigationBarItem(icon: new Icon(Icons.account_balance), title: new Text("Balance"))
      ]),
    

    如果提供了 3 个以上的 BottomNavigationBar 项,则类型(如果未指定)将根据 https://docs.flutter.io/flutter/material/BottomNavigationBar/BottomNavigationBar.html 更改为 BottomNavigationBarType.shifting。

    【讨论】:

    • 考虑到你上面所说的:如何从 4 个项目中设置活动项目的颜色?我已经尝试过使用 fixedColor,但也没有用。
    • @AlexandraDamaschin 我确定这已在此处或 GitHub 问题中讨论过。如果找不到,请创建一个新问题。我不知道它,我目前没有使用 Flutter。
    猜你喜欢
    • 1970-01-01
    • 2021-10-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-09-03
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多