有没有办法在 React Native 中设置正在呈现的 View 背后的整体 backgroundColor?例如,如果我使用 marginTop: 30
设置我的 View 样式,那么 View 上方会有一个空白区域。我想知道是否有办法改变这种背景颜色?
renderStoriesListView() {
if (this.state.dataSource.getRowCount() === 0) {
return (
<Loading>top stories</Loading>
)
} else {
return (
<View style={{marginTop: 30, backgroundColor: 'black'}}>
<RefreshableListView
dataSource={this.state.dataSource}
renderRow={this.renderStory}
loadData={this.loadTopStories}
refreshDescription="Refreshing top stories"
refreshingIndictatorComponent={<Refreshing />}
/></View>
)
}
},
render() {
return this.renderStoriesListView()
}
})
最佳答案
试试这个...
<View style={{backgroundColor: 'black'}}>
<View style={{marginTop: 30}}>
<RefreshableListView
dataSource={this.state.dataSource}
renderRow={this.renderStory}
loadData={this.loadTopStories}
refreshDescription="Refreshing top stories"
refreshingIndictatorComponent={<Refreshing />}
/></View></View>
关于javascript - React-Native 如何设置 View 后的整体背景色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33439592/