使用react-native-vector-icons的图标未显示在android屏幕上

时间:2019-02-06 20:18:51

标签: android react-native react-native-vector-icons

我是React-native的新手,enter image description here尝试实现标签导航器。我正在使用react-native-vector-icons。我试图在屏幕上显示图标,但没有显示任何图标。这就是我所做的

  

1-npm install react-native-vector-icons --save

     

2-react-native链接react-native-vector-icons

     

3-edited android / app / build.gradle

  project.ext.vectoricons = [
        iconFontNames: [ 'MaterialIcons.ttf', 'EvilIcons.ttf' ] 
    ]
  apply from: "../../node_modules/react-native-vector-icons/fonts.gradle"
  

4- react-native run-android

import React, { Component } from 'react'; 
import { StyleSheet, Text, View,Image,StatusBar,Button,TouchableOpacity} from 'react-native';
import { createBottomTabNavigator, createAppContainer } from 'react-navigation';
import Icon from 'react-native-vector-icons/Ionicons';
import profile from './profile';

export  class test extends Component
{ render()
    { 
        return (
            <View style={styles.container}>
                 <Text style={styles.text}>Test</Text>
                 </View>
             );
    }
}
export default createBottomTabNavigator({
'test':{screen:test,
navigationOption:{
tabBarLabel:'test',
tabBarIcon:({tintColor})=>(
<Icon name="rocket" color={tintColor} size={40}/>
 )}},
 'Profile': { screen:profile,
    navigationOption:{
        tabBarLabel:'profile',
        tabBarIcon:({tintColor})=>(
            <Icon name="rocket" color={tintColor} size={40}/>
) } }     
},{

    navigationOption:{
        tabBarVisible:true
    },   
    tabBarOptions:{
        activeTintColor:'red',
        inactiveTintColor:'grey'
    }
});

const styles= StyleSheet.create({
    container:{
                 flexGrow:1,

                  backgroundColor:'#1c313a',
                justifyContent:'center',
                alignItems:'center'
              },
                text:{
                fontSize:25,
                fontWeight:'500',
                color :'#fff',
                paddingHorizontal:16 ,
                textAlign:'center'
               }
});

enter image description here

1 个答案:

答案 0 :(得分:1)

我认为图标类型rocket的名称Ionicons不存在。 您可以在这里检查

https://oblador.github.io/react-native-vector-icons/

也许您会使用其他类型或名称。