首页 > 解决方案 > Card 组件中的背景颜色

问题描述

如何更改整张卡片的背景颜色?

在以下代码的情况下,颜色仅在 Item 元素下发生变化

整张牌一直是白色的

<Card style={{flex:1, backgroundColor:'blue'}}>
    <CardItem header>
        <Text>List of users</Text>
    </CardItem>
    <List
        leftOpenValue={75}
        rightOpenValue={-75}
        dataSource={this.ds.cloneWithRows(this.state.data[0].users)}
        disableLeftSwipe = {true}
        renderRow={(item) => this._renderContent(item)}
    />
</Card>

标签: react-nativenative-base

解决方案


您已为每个 cardItem 明确设置背景颜色

  <Card style={{flex:1, backgroundColor:'blue'}}>
        <CardItem header style={{backgroundColor:'blue'}}>
            <Text>List of users</Text>
        </CardItem>
        <List
            style={{backgroundColor:'blue'}}
            leftOpenValue={75}
            rightOpenValue={-75}
            dataSource={this.ds.cloneWithRows(this.state.data[0].users)}
            disableLeftSwipe = {true}
            renderRow={(item) => this._renderContent(item)}
        />
    </Card>

推荐阅读