android - 使用 RN 和 expo 更改 android 上的导航栏?

标签 android reactjs react-native expo

我开始在 Expo 中使用 React Native,遇到了我的第一个问题。我想更改 Android 上导航栏的颜色。不幸的是,我不知道该怎么做。

我尝试使用 https://github.com/thebylito/react-native-navigation-bar-color#readme但它打印出以下错误:

TypeError: TypeError: null is not an object (evaluating 'NavigationBarColor.changeNavigationBarColor')


if (Platform.OS == 'android') {
  changeNavigationBarColor('#f00', true);
}

最佳答案

此功能已于 8 月 9 日合并到 expo 中。
您需要将这些指令添加到 app.json

{
  "androidNavigationBar": {
     /*
        Determines to show or hide bottom navigation bar.
        "true" to show, "false" to hide.
        If set to false, status bar will also be hide. As it's a general rule to hide both status bar and navigation bar on Android developer official docs.
      */
    "visible": BOOLEAN,
    /*
      Configure the navigation bar icons to have light or dark color.
      Valid values: "light-content", "dark-content".
    */
    "barStyle": STRING,

    /*
      Configuration for android navigation bar.
      6 character long hex color string, eg: "#000000"
    */
    "backgroundColor": STRING
  }
}

这是包含更多信息的拉取请求 https://github.com/expo/expo/pull/5280

关于android - 使用 RN 和 expo 更改 android 上的导航栏?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56729621/

相关文章:

Android 可访问性对讲说出 fragment 的标题

Android SetNewPassword Intent 返回 RESULT_FIRST_USER

reactjs - 在 Material-UI 中使用自定义主题时已弃用的版式警告

android - React-Native 更改 iOS 和 Android 文件夹的默认位置

javascript - 通过映射的 onPress 事件切换对象属性

Android 应用不支持 Google Play 设备目录中的热门设备

android - 升级到 gradle 3.+ 时出现应用程序 build.gradle 同步问题

android - 移除 TextInput 下划线 React-Native

javascript - 使用 React.js 插入 MongoDB 文档

具有 3 张卡片分页布局的 React-Native FlatList