我试图在我的中使用ToolbarAndroid。
但是没有呈现工具栏。我有遗漏什么吗?
下面是片段:
toolbar.js
import React, {
Component
} from 'react';
import {
View,
Text,
ToolbarAndroid,
StyleSheet
} from 'react-native';
import Icon from 'react-native-vector-icons/Ionicons';
export default class Toolbar extends Component {
render() {
return(
<Icon.ToolbarAndroid
title = {this.props.title}
titleColor = 'black'
navIconName = "android-menu"
style = {styles.toolbar}
/>
);
}
}
const styles = StyleSheet.create({
toolbar: {
backgroundColor: 'firebrick',
height: 56
}
});然后,我将这个文件导入到我的主文件中,在主文件中呈现组件。
更新
我将宽度应用于工具栏,现在它正在显示。但是,为什么我们必须使用宽度,以及使工具栏沿着整个屏幕呈现的合适值是什么?
是虫子吗?
更新样式
const styles = StyleSheet.create({
toolbar: {
backgroundColor: 'firebrick',
height: 56,
width: 300
}
});发布于 2016-05-05 10:22:42
这是此类组件的一个工作示例(但不是相同的):
<ToolbarAndroid
title = {this.props.title}
titleColor = 'black'
navIconName = "android-menu"
>
<View style={styles.toolbar}>
<Text>{this.props.title}</Text>
</View>
</ToolbarAndroid>您必须将子视图传递给ToolbarAndroid。此外,也不支持使用像firebase这样的颜色名称。
https://stackoverflow.com/questions/37047244
复制相似问题