React native 列表项上的背景色不为';不行?

React native 列表项上的背景色不为';不行?,react-native,background-color,listitem,react-native-elements,React Native,Background Color,Listitem,React Native Elements,我是第一次做一个列表项,如果我使用以下代码,没有发现任何变化: **编辑 从“React”导入React; 从“react native”导入{StyleSheet,View}; 从“react native elements”导入{ListItem}; 从“反应本机矢量图标/唯物主义者”导入唯物主义者; 从“反应本机矢量图标/材料通讯图标”导入材料通讯图标; 导出默认类ChangePassword扩展React.Component{ 建造师(道具){ 超级(道具); this.state={}

我是第一次做一个列表项,如果我使用以下代码,没有发现任何变化:

**编辑

从“React”导入React;
从“react native”导入{StyleSheet,View};
从“react native elements”导入{ListItem};
从“反应本机矢量图标/唯物主义者”导入唯物主义者;
从“反应本机矢量图标/材料通讯图标”导入材料通讯图标;
导出默认类ChangePassword扩展React.Component{
建造师(道具){
超级(道具);
this.state={};
}
accountIcon=()=>(
);
changePasswordIcon=()=>(
);
render(){
返回(
);
}
}
有人能给我解释一下为什么会这样,以及我如何解决这个问题吗


非常感谢,感谢您抽出时间

使用
react native elements
。因此,必须使用该模块的样式

您可以使用
containerStyle={{backgroundColor:“}}}

如果您只想更改标题的颜色,
titleStyle={{{backgroundColor:“}}}

示例


如果不起作用,
将删除
列表项的内容。你唯一能看到的就是底线。如果我在容器周围放置一个带有
flex:1
的容器,您会看到颜色,但它位于
ListItem
本身的下方。很奇怪,有没有办法解决这个问题?我在控制台打开了它。我可以在PadView中更改背景图像,但是如何访问PadView
     import React from "react";
import { StyleSheet, View } from "react-native";
import { ListItem } from "react-native-elements";
import MaterialIcons from "react-native-vector-icons/MaterialIcons";
import MaterialCommunityIcons from "react-native-vector-icons/MaterialCommunityIcons";

export default class ChangePassword extends React.Component {
  constructor(props) {
    super(props);
    this.state = {};
  }

  accountIcon = () => (
    <MaterialIcons name="account-box" size={35} type="MaterialIcons" />
  );
  changePasswordIcon = () => (
    <MaterialCommunityIcons
      name="textbox-password"
      size={35}
      type="MaterialCommunityIcons"
    />
  );

  render() {
    return (
      <View>
        <ListItem title="Account" leftIcon={this.accountIcon} bottomDivider />
        <View style={{ backgroundColor: "#007bff" }}>
          <ListItem
            title="Change password"
            leftIcon={this.changePasswordIcon}
            bottomDivider
          />
        </View>
      </View>
    );
  }
}