我希望在水平FlatList中有10个图像,设备屏幕的高度和图像之间没有空格,但问题是我在下面的图像之间得到的空间是代码:
constructor(){
super();
this.state={
data:[
{
image:require('./assets/images/2.jpg')
},
{
image:require('./assets/images/1.jpg')
},
{
image:require('./assets/images/3.jpg')
},
{
image:require('./assets/images/4.jpg')
},
{
image:require('./assets/images/5.jpg')
},
{
image:require('./assets/images/7.jpg')
},
{
image:require('./assets/images/8.jpg')
},
{
image:require('./assets/images/9.jpg')
},
{
image:require('./assets/images/10.jpg')
},
]
}
}
render() {
var Dimensions = require('Dimensions');
var {
width,
height
} = Dimensions.get('window');
return (
<FlatList
horizontal
data={this.state.data}
style={{height:this.height}}
renderItem={({item}) => {
return (
<View >
<Image style={{flex:1}} resizeMode='contain' source={item.image} />
</View>
);
}}
keyExtractor={(item,index)=>item.image}
/>
);
}
尝试了不同的内容,例如contentContainerStyle,但这也无效。