В React Native я пытаюсь создать ячейку сетки. Проблема в том, что когда ячейка одна, она занимает 100 процентов ширины. Мне нужно, чтобы все ячейки были одинаковой высоты и ширины. если ячейка одна или несколько, ширину изменять не нужно. Вот мой код и снимок экрана, см. Ширину последней ячейки.
render() {
let imageURL = "https://randomuser.me/api/portraits/"
let partofURL = "women/"
return (
<Container>
<Header>
</Header>
<Content padder>
<FlatList
data = {this.state.ary_data}
numColumns = {3}
itemWidth = {150}
renderItem = {({ item }) => (
<View style = {{
flex: 1, margin: 5,
backgroundColor: '#ddd', borderColor: '#000000',
borderWidth: 1,
height: 130
}} >
<Grid>
<TouchableOpacity onPress = {() =>this.didselectoncell(item.id)}>
<Row style = {{ height: '20%' }} >
<Text>name:{item.name}</Text>
</Row>
<Row style = {{ height: '20%' }}>
<Text style = {{textAlign:'center',width:'100%'}}>Detail:{item.detail}</Text>
</Row>
<Row >
<Image
style = {{ width: 70, height: 70,
backgroundColor:'#000000',
marginLeft:'auto',
marginRight:'auto' }}
source = {{ uri: imageURL + partofURL + item.id + '.jpg' }}>
</Image>
</Row>
</TouchableOpacity>
</Grid>
</View>
)}
refreshing = {this.state.refreshing}/>
</Content>
</Container>
);
}
}
Waoooo Спасибо,





Обратитесь к React Native FlatList со столбцами, ширина последнего элемента