我正在尝试设置ListItem
组件的背景色:
<FlatList
data={this.props.search.videos}
renderItem={({ item }) => (
<View style={{ backgroundColor: "red" }}>
<ListItem
title={item.title}
onPress={() => this.onPress(item.id)}
/>
</View>
)}
contentContainerStyle={{
backgroundColor: "red",
overflow: "hidden",
backgroundColor: "#00336690"
}}
keyExtractor={item => item.id.toString()}
ItemSeparatorComponent={this.renderSeparator}
/>
backgroundColor
始终显示为白色,如何更改?
ListItem:
<ListItem
underlayColor="red"
style={{ backgroundColor: "#000" }}
title={item.title}
onPress={() => this.onPress(item.id)}
/>
答案 0 :(得分:0)
我认为您需要在ListItem
本身上设置样式。
<FlatList
data={this.props.search.videos}
renderItem={({ item }) => (
<View>
<ListItem
title={item.title}
onPress={() => this.onPress(item.id)}
style={{ backgroundColor: "red" }}
/>
</View>
)}
contentContainerStyle={{
backgroundColor: "red",
overflow: "hidden",
backgroundColor: "#00336690"
}}
keyExtractor={item => item.id.toString()}
ItemSeparatorComponent={this.renderSeparator}
/>
答案 1 :(得分:0)
尝试从
删除一种backgroundColorcontentContainerStyle={{
backgroundColor: "red",
overflow: "hidden",
backgroundColor: "#00336690"
}}
像这样
<FlatList
contentContainerStyle={{
backgroundColor: "red",
overflow: "hidden",
}}
data={this.props.search.videos}
renderItem={({ item }) => (
<View>
<ListItem
style={{ backgroundColor: "red" } }
title={item.title}
onPress={() => this.onPress(item.id)}
/>
</View>
)}
keyExtractor={item => item.id.toString()}
ItemSeparatorComponent={this.renderSeparator}
/>