似乎position:absolute
在使用中某个元素无法使用justifyContent
或居中alignItems
。有一种解决方法可以使用,marginLeft
但即使使用尺寸来检测设备的高度和宽度,也无法在所有设备上显示相同的结果。
bottom: {
position: 'absolute',
justifyContent: 'center',
alignItems: 'center',
top: height*0.93,
marginLeft: width*0.18,
},
bottomNav: {
flexDirection: 'row',
},
将您想要的孩子包裹在View中居中,然后将View设为绝对。
<View style={{position: 'absolute', top: 0, left: 0, right: 0, bottom: 0, justifyContent: 'center', alignItems: 'center'}}>
<Text>Centered text</Text>
</View>
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句