【问题标题】:react-native-vector-icon does not work properlyreact-native-vector-icon 无法正常工作
【发布时间】:2020-06-08 22:58:17
【问题描述】:

我正在使用来自 type ('mask') 的 react-native 图标。但是,当我运行该应用程序时,该图标不显示。 icon to the left

谁能给个建议?可能是什么问题?

代码是:

import Icon from 'react-native-vector-icons/Entypo'
<Icon name={'mask'} size={23} color={'rgba(255, 255, 255, 1)'} 
          style={styles.usernameIcon}/>

【问题讨论】:

  • 请编辑您的问题并显示您使用过的代码Icon
  • 链接这个库对我有用
  • @SagarKulkarni,您好。我确实添加了代码,但它已经消失了,我现在将重新编辑它,sry。

标签: react-native package icons frontend


【解决方案1】:

通过将以下代码添加到android/app/build.gradle解决它

project.ext.vectoricons = [
    iconFontNames: [ 'MaterialIcons.ttf', 'EvilIcons.ttf', 'AntDesign.ttf', 'Entypo.ttf', 'EvilIcons.ttf', 'Feather.ttf', 'FontAwesome.ttf', 'FontAwesome5_Brands.ttf', 'FontAwesome5_Regular.ttf', 'FontAwesome5_Solid.ttf', 'Foundation.ttf', 'Ionicons.ttf', 'MaterialCommunityIcons.ttf', 'SimpleLineIcons.ttf', 'Octicons.ttf', 'Zocial.ttf' ]
]

apply from: "../../node_modules/react-native-vector-icons/fonts.gradle"

【讨论】: