我需要使按钮宽度相等,如果可能的话,对齐容器的边缘 .
我试过以下没有成功:
<View style={{flex: 1,
flexDirection: 'row',
alignItems: 'center',
justifyContent: 'center'}>
<View style={{flex: 1}}>
<Button title="Button 1"/>
</View>
<View style={{flex: 1}}>
<Button title="Button 2"/>
</View>
</View>
我错过了什么?
1 回答
对于宽度,您只需将按钮的宽度设置为100%即可 . 如果我通过将它们与边缘对齐来正确理解您的意思,则可以在容器上使用
justifyContent: 'space-between'
.PS . 您可能希望在包含按钮的视图上添加一些填充
你会有类似的东西: