ShowWithText boolean to set whether to display the title information next to the icon3.3.contentInSetEnd number is used to set the spacing between the right side of the ToolBar and the right edge of the screen.
3.4.contentInsetStart number is used to set the spacing between the left and right edges of the ToolBar.
3.5.logo optionalImageSource optional image resource used to set the Logo icon of the Toolbar
3.6.navIcon optionalImageSource: Optional image resources used to set navigation icons
3.7.onActionSelectedfunction: callback method when our function is selected. This method will pass in only one parameter: Click function index information in the function list
3.8.onIconClickedfunction callback method when the icon is selected
3.9.overflowIcon optionalImageSource
3.10. The functional sequence in the rtl setting toolbar is from Right To Left (RTL: Right To Left ). To make this effect take effect, you must use AndroidMainifest In the Android app. add android: supportsRtl = "true" to the application node in xml, and then call the following code in the onCreate method of your main Activity (for example, MainActivity): setLayoutDirection (LayoutDirection ction. RTL ).
3.11.subtitle string set the subtitle of the toolbar
3.12.subtitleColor color set the subtitle color of the toolbar
3.13.title string set the toolbar title
3.14.titleColor color set the title color of the toolbar
(4) ToolbarAndroid instance description. The instance simply displays the title/sub-title of the Toolbar and the function list and navigation icon. The instance code is as follows:
'Use strict '; import React, {AppRegistry, Component, StyleSheet, Text, View,} from 'react-native'; var ToolbarAndroid = require ('toolbarandroid '); class ToolBarAndroidDemo extends Component {render () {return (
) ;}} Var toolbarActions = [{title: 'create', icon: require ('. /ic_create_black_48dp.png '), show: 'alway'}, {title: 'filter'}, {title: 'settings', icon: require ('. /ic_settings_black_48dp.png '), show: 'always'},]; const styles = StyleSheet. create ({toolbar: {backgroundColor: '# e9eaed', height: 56,},}); AppRegistry. registerComponent ('toolbarandroiddemo', () => ToolBarAndroidDemo );
The running effect is as follows:
. Set only the title and function list without navigation icons. The Code is as follows:
'Use strict '; import React, {AppRegistry, Component, StyleSheet, View,} from 'react-native'; var ToolbarAndroid = require ('toolbarandroid '); class ToolBarAndroidDemo extends Component {render () {return (
) ;}} Var toolbarActions = [{title: 'create', icon: require ('. /ic_create_black_48dp.png '), show: 'alway'}, {title: 'filter'}, {title: 'settings', icon: require ('. /ic_settings_black_48dp.png '), show: 'always'},]; const styles = StyleSheet. create ({toolbar: {backgroundColor: '# e9eaed', height: 56,},}); AppRegistry. registerComponent ('toolbarandroiddemo', () => ToolBarAndroidDemo );
The running effect is as follows:
. Only the navigation icon exists, and the Logo icon and function list instance code is as follows:
'use strict';import React, { AppRegistry, Component, StyleSheet, View,} from'react-native';var ToolbarAndroid =require('ToolbarAndroid');class ToolBarAndroidDemo extends Component { render() { return (
); }}var toolbarActions =[ {title: 'Create', icon:require('./ic_create_black_48dp.png'), show: 'always'}, {title: 'Filter'}, {title: 'Settings', icon:require('./ic_settings_black_48dp.png'), show: 'always'},];const styles =StyleSheet.create({ toolbar: { backgroundColor: '#e9eaed', height: 56, },});AppRegistry.registerComponent('ToolBarAndroidDemo',() => ToolBarAndroidDemo);
The running effect is as follows:
4. The last point is that the ToolbarAndroid component also supports component nesting. Let's look at an example of ToolbarAndroid nested SwitchAndroid component. The function code is as follows:
'use strict';import React, { AppRegistry, Component, StyleSheet, View,} from'react-native';var ToolbarAndroid =require('ToolbarAndroid');var SwitchAndroid =require('SwitchAndroid');class ToolBarAndroidDemo extends Component { render() { return (
); }}var toolbarActions =[ {title: 'Create', icon:require('./ic_create_black_48dp.png'), show: 'always'}, {title: 'Filter'}, {title: 'Settings', icon:require('./ic_settings_black_48dp.png'), show: 'always'},];const styles =StyleSheet.create({ toolbar: { backgroundColor: '#e9eaed', height: 56, },});AppRegistry.registerComponent('ToolBarAndroidDemo',() => ToolBarAndroidDemo);
The running effect is as follows: