我如何在react native中的png图像后面添加文本?

问题描述 投票:0回答:1

伙计们,我想在本机图像(.png)后面添加文本吗?有ImageBackground。我只需要ImageForeground。

renderContactsItem = ({ item}) => {
return (
  <View style={styles.container}>
    <TouchableOpacity style={styles.itemContainer}
    onPress={() => this.props.navigation.navigate('Modal',{selectedItem:item},)}
    >
      <View style={[styles.card,{backgroundColor:item.color}]}>
        <Image
          style={styles.avatar}
          source={ item.picture }
        />
      </View>
    </TouchableOpacity>
  </View> 
)

};

javascript react-native
1个回答
0
投票

您应该使用ImageBackground而不是Image

<View style={styles.container}>
 <ImageBackground source={image} style={styles.image}>
   <Text style={styles.text}>Inside</Text>
 </ImageBackground>
</View>

请通过正式文件-Here

© www.soinside.com 2019 - 2024. All rights reserved.