简体   繁体   English

反应本机ToolbarAndroid操作图标不起作用

[英]React native ToolbarAndroid action icon not working

I am using react native vector icons to display icons for the actions on the toolbar. 我正在使用react native矢量图标在工具栏上显示操作的图标。 But it doesn't seem to work. 但这似乎不起作用。

Imports & Icon 导入和图标

import Icon from 'react-native-vector-icons/FontAwesome';
const myIcon = (<Icon name="compass" size={30} color="#900" />)

Main view 主视图

 <View style={styles.containerToolbar}>
     <ToolbarAndroid style={styles.toolbar}
         title="Test"
         actions={toolbarActions}
         onActionSelected={this.onActionSelected}>
     </ToolbarAndroid>
 </View>

var toolbarActions = [
    {title: 'Compass', icon:{myIcon} show: 'always'}
];

You can set the actions icon like this - 您可以这样设置操作图标-

var toolbarActions = [
  {title:'Compass', iconName:'compass', iconColor:"#900", iconSize:30, show:'always'}
];

Furthermore you need to use Icon.ToolbarAndroid instead of ToolbarAndroid . 此外,你还需要使用Icon.ToolbarAndroid而不是ToolbarAndroid

<Icon.ToolbarAndroid
  actions={toolbarActions}
  ....
>

More details here - https://github.com/oblador/react-native-vector-icons#usage-with-toolbarandroid 更多详细信息-https: //github.com/oblador/react-native-vector-icons#usage-with-toolbarandroid

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Icon.button 正在工作,但 Icon.ToolbarAndroid 在本机反应中不起作用 - Icon.button are working but Icon.ToolbarAndroid are not working in react native 动态navIconName工具栏Android,带有react-native-vector-icon - Dynamic navIconName ToolbarAndroid with react-native-vector-icon ToolbarAndroid 未在 React Native 中显示 - ToolbarAndroid is not displaying in react native ToolbarAndroid中的下拉图标+捕捉标题点击事件+搜索输入(反应原生) - Dropdown icon in ToolbarAndroid + catching title tap event + search input (react native) React-Native ToolbarAndroid不支持fontFamily - React-Native ToolbarAndroid does not support fontFamily 如何在 React Native 中在 ToolbarAndroid 上设置自定义字体 - How to set custom font on ToolbarAndroid in react native 反应本机通知图标不起作用 - React Native Notification Icon Not working 如何在react-native的ToolbarAndroid中设置navIcon的高度和宽度? - How to set the height and width of navIcon in ToolbarAndroid of react-native? react-native:使用徽标时ToolbarAndroid不显示标题 - react-native: ToolbarAndroid not displaying title when logo is used 在React Native中如何在ToolbarAndroid中显示首页和后方导航图标 - How to show home and back navigation icons in ToolbarAndroid in React Native
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM