工具栏Android未在react native中显示
我正在学习工具栏Android未在react native中显示,android,react-native,react-native-android,Android,React Native,React Native Android,我正在学习react native编程,使用它创建工具栏,但在我的例子中,它没有显示出来。我不明白我到底犯了什么错误 有人能帮我吗 import React, { Component } from 'react'; import { AppRegistry, Text, View, TextInput, TouchableOpacity, ToolbarAndroid } from 'react-native'; import { ToolBar } from 'react-native-
react native
编程,使用它创建工具栏,但在我的例子中,它没有显示出来。我不明白我到底犯了什么错误
有人能帮我吗
import React, { Component } from 'react';
import { AppRegistry, Text, View, TextInput, TouchableOpacity, ToolbarAndroid } from 'react-native';
import { ToolBar } from 'react-native-material-design';
class LoginComponent extends Component {
render() {
return (
<View style={{flex: 1, flexDirection: 'column', margin:10}}>
<ToolbarAndroid title="Login" titleColor="black"/>
<TextInput style={{height: 40, borderColor:'gray', borderWidth: .5}}
placeholder="Email address" underlineColorAndroid='transparent'/>
<TextInput style={{height: 40, borderColor:'gray', borderWidth: .5}}
placeholder="Password" secureTextEntry={true} underlineColorAndroid='transparent'/>
<TouchableOpacity style={{ height: 40, marginTop: 10 , backgroundColor: '#2E8B57'}}>
<Text style={{color: 'white', textAlign: 'center', marginTop: 10, fontWeight: 'bold'}}>LOG IN</Text>
</TouchableOpacity>
</View>
);
}
}
AppRegistry.registerComponent('Myntra', () => LoginComponent);
import React,{Component}来自'React';
从“react native”导入{AppRegistry、Text、View、TextInput、TouchableOpacity、ToolbarAndroid};
从“react native material design”导入{ToolBar};
类LoginComponent扩展组件{
render(){
返回(
登录
);
}
}
AppRegistry.registerComponent('Myntra',()=>LoginComponent);
这是一个很好的例子。解决方法是为工具栏设置一个高度。这是一个。一个解决方法是为你的工具栏Android设置一个高度。因为我是react native的新手,这是迄今为止我找到的最好的解决方案,希望能有所帮助。 首先,, 添加
npm安装@react native community/toolbar安卓--save
或
纱线爱好者添加纱线添加@react native community/toolbar android
其次,运行react native start
命令
第三,运行react原生运行android
快乐编码:)由于我是react native的新手,这是迄今为止我找到的最好的解决方案,希望能有所帮助。 首先,, 添加
npm安装@react native community/toolbar安卓--save
或
纱线爱好者添加纱线添加@react native community/toolbar android
其次,运行react native start
命令
第三,运行react原生运行android
快乐编码:)谢谢。我也设置了高度,但它仍然没有显示。请查看更新的代码我不确定这是否是打字错误,但您的工具栏样式设置为
style={styles.styles}
。我认为应该是style={styles.toolbar}
。如果不起作用,您可以尝试设置工具栏的高度
属性吗?谢谢。我也设置了高度,但它仍然没有显示。请查看更新的代码我不确定这是否是打字错误,但您的工具栏样式设置为style={styles.styles}
。我认为应该是style={styles.toolbar}
。如果不起作用,能否尝试设置工具栏的height
属性?