【发布时间】:2019-06-11 13:23:24
【问题描述】:
我使用 React native 的水平 FlatList 并在其中使用 ListItem 和 Native base 的 Card 来呈现我的列表项。 它可以工作,但项目之间的空间太大,我无法减少它。
这是平面列表:
<FlatList
horizontal data={this.props.data}
showsHorizontalScrollIndicator={false}
keyExtractor={item => item.title}
renderItem={this.renderItem}
/>
这是renderItem:
renderItem = ({ item }) => {
return (
<ListItem onPress={() =>
this.props.navigate(this.state.navigateTO,{
id:item['id'],
title:item['title'],
top_image:item['top_image'],
token:this.state.token,
lan:this.state.lan,
type:this.state.type,
}
)} >
<Card style={{height:320, width: 200}}>
<CardItem cardBody>
<Image source={{uri:item['top_image']}}
style={{height:200, width: 200}}/>
</CardItem>
<CardItem>
<Left>
<Body>
<Text >{item['title']}</Text>
<Text note>{item['city']} </Text>
</Body>
</Left>
</CardItem>
</Card>
</ListItem>
);
};
【问题讨论】:
-
您是否尝试过定义自定义
ItemSeparatorComponent并将其作为 FlatList 属性传递? -
如何使用 ItemSeparatorComponent 减少空间?!我相信它是用来增加空间的。
标签: android reactjs react-native react-native-flatlist native-base