【发布时间】:2019-10-28 16:17:16
【问题描述】:
我正在学习 react-native,并且希望 Parent 使用 flex 而不是静态的高度/宽度值动态地占据整个屏幕。它适用于 {height:714, width:393},但是当我用 flex:1 替换它们时,所有元素都会缩小到屏幕顶部。
样式:
const 样式 = StyleSheet.create({ 容器: { 背景颜色:'紫色', 填充:5, // 弹性:1, 身高:714, 宽度:393, },
bigBlackText: {
color: 'black',
fontSize: 18,
},
bigWhiteText: {
color: 'white',
fontSize: 19,
},
col1: {
backgroundColor: 'yellow',
flexDirection: 'row',
flex: 1,
},
col11: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
margin: 5,
backgroundColor: 'orange',
},
col12: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
margin: 5,
backgroundColor: 'orange',
},
col13: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
margin: 5,
backgroundColor: 'orange',
},
col2: {
flex: 1,
backgroundColor: 'red',
},
col21: {
flex: 1,
justifyContent: 'space-around',
alignItems: 'center',
backgroundColor: 'brown',
margin: 5
},
col22: {
flex: 1,
justifyContent: 'space-around',
alignItems: 'center',
backgroundColor: 'brown',
margin: 5
},
col23: {
flex: 1,
justifyContent: 'space-around',
alignItems: 'center',
backgroundColor: 'brown',
margin: 5
},
col3: {
flex: 1,
backgroundColor: 'cyan',
flexDirection: 'column',
},
col31: {
flexDirection: 'row',
flex: 1,
},
col31r1: {
flex: 1,
justifyContent: 'space-around',
alignItems: 'center',
backgroundColor: 'green',
margin: 5,
},
col31r2: {
flex: 1,
justifyContent: 'space-around',
alignItems: 'center',
backgroundColor: 'green',
margin: 5,
},
col32: {
flexDirection: 'row',
flex: 1,
},
col32r1: {
flex: 1,
justifyContent: 'space-around',
alignItems: 'center',
backgroundColor: 'green',
margin: 5,
},
col32r2: {
flex: 1,
justifyContent: 'space-around',
alignItems: 'center',
backgroundColor: 'green',
margin: 5,
},
});
【问题讨论】:
标签: react-native react-native-android