如何在React-Native中设置视图后面的整体背景颜色

时间:2015-10-30 15:31:18

标签: javascript ios css react-native

有没有办法在React Native中呈现的视图后面设置整体backgroundColor?例如,如果我使用marginTop: 30设置我的视图样式,那么视图上方会有一个空白空白。我想知道是否有办法改变这种背景颜色?

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()
}
})

1 个答案:

答案 0 :(得分:0)

试试这个......

<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>