javascript - React-Native 如何设置 View 后的整体背景色

标签 javascript ios css react-native

有没有办法在 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/

相关文章:

javascript - Visual Studio 中的 JsHint 与 Ext Js

javascript - 将输入字符串分解为单个单词

javascript - 将十进制字符串从 php 传递到 jquery

javascript - 混合 CSS 和 Javascript 事件处理程序

css - 适用于所有设备的可重用 html 包装器

html - 对齐3个div同时左右仅repeat-x且中间居中

ios - 在加载 tableView 时展开可选值时意外发现 nil

php - 使用 PHP 在 iOS 社交网络应用程序中发送好友请求并添加好友?

ios - 一直给我的单例执行不正确

css - 2 列 100% 高度使用 HTML