我有一个非常规则的垂直FlatList,没什么特别的,但是我发现了一些奇怪的样式错误:列表本身的背景颜色总是白色,这使我的列表项(也有白色背景)难以区分。有什么办法可以解决?我的代码:
<FlatList
contentContainerStyle={{
backgroundColor:'purple',
}}
ListHeaderComponent={
<HeaderView />
}
data={places}
renderItem={({item}) => (
<PlaceListItem place={item} navigation={navigation} />
)}
/>
和PlaceListItem:
const styles = StyleSheet.create({
container: {
flex: 1,
borderWidth: 1,
borderRadius: 15,
borderColor: 'white',
overflow: 'hidden',
marginBottom: 10,
},
infoContainer: {
flex: 1,
backgroundColor: 'white',
paddingStart: 10,
},
image: {/*just size*/},
title: {/*just font style*/},
item: {/*just font style*/},
})
<SelectionHighlight
onPress={() => doStuff()}>
<View style={styles.container}>
<Image
style={styles.image}
source={{
uri: photo,
}}
/>
<View style={styles.infoContainer}>
<Text style={styles.title}>{title}</Text>
<Text style={styles.item}>{address}</Text>
</View>
</View>
</SelectionHighlight>
结果是:
Android
iOS
backgroundColor:'white'
设置为TouchableHighlight
,由于某种原因,它在Android上运行正常,但在iOS上给出了此结果。将backgroundColor: 'transparent'
设置为TouchableHighlight
解决了该问题。