Tôi đang cố gắng để có được Thanh công cụ Android cơ bản hiển thị trên chế độ xem gốc React của mình và tôi đang gặp sự cố. Với mã hiện tại của tôi, nó chạy tốt (không có lỗi hoặc bất kỳ điều gì) nhưng Thanh công cụ không có ở đó. Bất kỳ đề xuất nào về những gì tôi đang làm sai? Cảm ơn trước! ToolBarAndroid không hiển thị trong 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);
Bạn đã bao giờ tìm ra điều này chưa? Có cùng một vấn đề. – Nolan
Trong phiên bản 0.26, DrawerLayoutAndroid dường như cần #drawerHeight được đặt thành một số giá trị tùy ý để được gắn kết. Kể từ 0.27.1, DrawerLayoutAndroid không cần chiều cao nữa. – jhohlfeld