4

我正在尝试使用 FlatList 进行 flexGrow,但它无法与 ListView 一起使用。即使屏幕上有空间,这些项目也会以 minWidth 值呈现。示例代码:

class ProductListScreen extends Component {
    render () {
    return (<FlatList
    contentContainerStyle={styles.list}
    showsVerticalScrollIndicator={false}
    data={[{key: 'a'}, {key: 'b'},{key: 'c'},{key: 'd'}, {key: 'e'},{key: 'f'},{key: 'g'}, {key: 'h'},{key: 'i'},{key: 'j'}]}
    renderItem={this.renderItem}
    />);
    renderItem({ item, index }) {
    return <View style={{
    flexGrow: 1,
    margin: 5,
    minWidth: 154,
    maxWidth: 223,
    height: 304,
    maxHeight:304,
    backgroundColor: '#CCC',
    }}/>;
    }
}
    var styles = StyleSheet.create({
      list: {
        justifyContent: 'center',
        flexDirection: 'row',
        flexWrap: 'wrap'
      })
4

0 回答 0