ReactNative FlatList项目之间的空白在iOS中始终为白色

问题描述 投票:0回答:1

我有一个非常规则的垂直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

Android - space between items has proper color, as set in <code>contentContainerStyle</code>

iOS

iOS - space between items is white

react-native react-native-ios
1个回答
0
投票
我发现了问题,原来是我自己的错误。我将backgroundColor:'white'设置为TouchableHighlight,由于某种原因,它在Android上运行正常,但在iOS上给出了此结果。将backgroundColor: 'transparent'设置为TouchableHighlight解决了该问题。
© www.soinside.com 2019 - 2024. All rights reserved.