我想要獲得一個基本的Android工具欄,以便在我的React本機視圖上呈現,並且遇到麻煩。用我目前的代碼,它運行良好(沒有錯誤或任何東西),但工具欄不在那裏。任何關於我在做什麼的錯誤?提前致謝! ToolBarAndroid無法在ReactNative中呈現
'use strict';
const React = require('react-native');
const MaterialKit = require('react-native-material-kit');
const {
AppRegistry,
DrawerLayoutAndroid,
StyleSheet,
Text,
View,
ToolbarAndroid,
} = React;
const DRAWER_REF = 'drawer';
const OpenLightApp = React.createClass({
render: function() {
const navigationView = (
<View style={{flex: 1, backgroundColor: '#88D8EC'}}>
<Text style={{margin: 10, fontSize: 15, textAlign: 'left'}}>Drawer Item</Text>
</View>
);
return (
<DrawerLayoutAndroid
drawerWidth={300}
ref={DRAWER_REF}
drawerPosition={DrawerLayoutAndroid.positions.Left}
renderNavigationView={() => navigationView}>
<View style={styles.container}>
<ToolbarAndroid
navIcon={require('image!hamburger')}
title="OpenLight"
titleColor="black"
style={styles.toolbar}
onIconClicked={() => this.refs[DRAWER_REF].openDrawer()} />
<Text style={styles.welcome}>
Example Text
</Text>
<Text style={styles.instructions}>
To get started, edit index.android.js
</Text>
<Text style={styles.instructions}>
Shake or press menu button for dev menu
</Text>
</View>
</DrawerLayoutAndroid>
);
}
});
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#F5FCFF',
},
welcome: {
fontSize: 20,
textAlign: 'center',
margin: 10,
},
instructions: {
textAlign: 'center',
color: '#333333',
marginBottom: 5,
},
toolbar: {
backgroundColor: '#00a2ed',
height: 56,
},
});
AppRegistry.registerComponent('OpenLightApp',() => OpenLightApp);
你有沒有想過這個?有完全相同的問題。 – Nolan
在版本0.26中,DrawerLayoutAndroid似乎需要將#drawerHeight設置爲某個任意值才能進行掛載。從0.27.1開始,DrawerLayoutAndroid不再需要高度。 – jhohlfeld