我正在尝试在Flexbox中(以及React Native中)创建此布局,但无论我做什么,左侧和右侧按钮都拒绝展开到容器宽度的50%。它们始终是其内容大小。
我正在使用嵌套容器。按钮位于一个列式Flex容器中,该容器嵌套在一个行式Flex容器中,该容器还包含图像。
我正在使用嵌套容器。按钮位于一个列式Flex容器中,该容器嵌套在一个行式Flex容器中,该容器还包含图像。
这是我的JSX:
<View style={{
display: 'flex',
flex: 1,
flexDirection: 'column'}}>
<Image
style={{flex: 1, zIndex: 1, width: '100%', height: '100%'}}
resizeMode='cover'
resizeMethod='resize'
source={require('./thumbs/barry.jpg')}
/>
<View style={{
display: 'flex',
flexDirection: 'row',
flex: 0,
width: '100%',
height: 100}} >
<Button style='flex: 1' title="LEFT" onPress={() => {}} />
<Button style='flex: 1' title="RIGHT" onPress={() => {}} />
</View>
</View>
非常感谢所有的回复...
Dimensions
可能适合你:https://dev59.com/WlwX5IYBdhLWcg3w2iku#33312563 - serraosays