【发布时间】:2017-07-02 18:14:57
【问题描述】:
概述 我已经尝试在 android 上使用 flex box 一个小时了,但似乎无法让它工作。因此,我从 react-native 站点获取了一个简单的 sn-p 来演示我的问题。
主要问题
exampleContainer: { flex: 1 }
不会占安卓屏幕空间。
图片校样
代码片段
export default class App extends Component {
constructor(props){
super(props);
this.state = {
environment: props.environment,
message: `Environment: ${props.environment}`
}
}
static defaultProps() {
return {environment: "Unknown"}
}
render(){
return (
// Try setting `alignItems` to 'flex-start'
// Try setting `justifyContent` to `flex-end`.
// Try setting `flexDirection` to `row`.
<View style={{
flex: 1,
alignSelf: 'stretch',
flexDirection: 'column',
justifyContent: 'center',
alignItems: 'center'
}}>
<View style={{width: 50, height: 50, backgroundColor: 'powderblue'}} />
<View style={{width: 50, height: 50, backgroundColor: 'skyblue'}} />
<View style={{width: 50, height: 50, backgroundColor: 'steelblue'}} />
</View>
);
}
}
更新 我通过为根节点 (./index..js) 赋予 flex 样式来解决此问题。
【问题讨论】:
标签: react-native flexbox react-native-android