您不需要在子组件上声明 flex 属性,只要您在父组件上声明了 flex-direction: 'row' 属性即可。
我在rnplay 上重新创建了设计。
'use strict';
var React = require('react-native');
var {
AppRegistry,
StyleSheet,
Text,
View,
} = React;
var SampleApp = React.createClass({
render: function() {
return (
<View style={styles.container}>
<View style={styles.header}></View>
<View style={styles.tableView}>
<Text style={styles.heading}>ACCOUNT</Text>
<Text style={styles.subHeading}>Log Out</Text>
<Text style={styles.heading}>COMPANY</Text>
<Text style={styles.subHeading}>About</Text>
<Text style={styles.subHeading}>Legal</Text>
<Text style={styles.subHeading}>Rate on the App Store</Text>
<Text style={styles.subHeading}>Server</Text>
</View>
</View>
);
}
});
var styles = StyleSheet.create({
container: {
flexDirection: 'column',
flex: 1
},
tableView: {
backgroundColor: '#EFEFF4',
flexDirection: 'column'
},
tableViewSection: {
flexDirection: 'column',
flex: 1,
backgroundColor: '#ffffff'
},
header: {
backgroundColor: '#0c65ab',
height:60
},
heading: {
paddingTop:20,
paddingLeft:15,
paddingBottom:10,
fontSize:17,
color: '#77777c',
},
subHeading: {
paddingTop:20,
paddingLeft:20,
paddingBottom:20,
fontSize:18,
backgroundColor: '#ffffff'
}
});
AppRegistry.registerComponent('SampleApp', () => SampleApp);