我有以下几点
<View style={{maxWidth: 700}}>
<View style={{backgroundColor: 'red', flexDirection: 'row', justifyContent: 'space-between'}}>
<Text>Left Item</Text>
<Text>Right Item</Text>
</View>
</View>
正如我在大型设备上预期的那样(垂直黑线是模拟器屏幕的边缘).
我只想把它放在屏幕中央.
当我试图通过向父对象添加alignSelf:"center"来执行此操作时
<View style={{maxWidth: 700, alignSelf: 'center'}}>
<View style={{backgroundColor: 'red', flexDirection: 'row', justifyContent: 'space-between'}}>
<Text>Left Item</Text>
<Text>Right Item</Text>
</View>
</View>
宽度丢失了.
我认为这是因为默认情况下它是"拉伸"的.有没有一种方法既可以拉伸内容以使用maxWidth,又可以使其在屏幕上居中?