React Native:如何在 android 的 tabBar 中添加图标

React Native: how to add icon in tabBar for android

我想在 tabView 中为 android 添加图标。我的代码看起来:

<ScrollableTabView>
            <View style={styles.container} tabLabel='Menu Button'>
            </View>
            <View style={styles.container} tabLabel='My App'>
            </View>         
            <View style={styles.container} tabLabel='Settings'>
            </View>  
</ScrollableTabView>

我想要图标而不是 菜单按钮 设置 。 如何使用图标而不是 tabLabel?

我假设您正在使用: https://github.com/skv-headless/react-native-scrollable-tab-view

此解决方案应该有效:

<ScrollableTabView>
    <View style={styles.container} tabLabel='android-menu'>
    </View>
    <View style={styles.container} tabLabel='My App'>
    </View>         
    <View style={styles.container} tabLabel='android-settings'>
    </View>  
</ScrollableTabView>

完整的图标列表可在此处获得:

https://github.com/skv-headless/react-native-scrollable-tab-view/blob/ee5d99950fad9c4c1129d029d7bfaea130df72d1/examples/FacebookTabsExample/android/app/src/main/assets/ion.json

编辑 1:

此示例演示了在 tabLabel 上使用图标而不是文本: https://github.com/skv-headless/react-native-scrollable-tab-view/tree/master/examples/FacebookTabsExample