简体   繁体   English

图像从带有阴影的容器中溢出

[英]Image is overflowing from container with shadow

I'm trying to create a custom card view for my RN app, right now I'm working the on the card's cover image but it seems the image container is overflowing the main container which seems to be caused by a conflict with box shadow ( Here I removed my styling).我正在尝试为我的 RN 应用程序创建自定义卡片视图,现在我正在处理卡片的封面图像,但似乎图像容器正在溢出主容器,这似乎是由与框阴影冲突引起的(在这里,我删除了我的样式)。

Here the code for my card component这是我的卡片组件的代码

export const LocationCard: React.FC<Props> = ({
  name,
  imageURI,
  description,
}) => {
  return (
    <View style={styles.card}>
      <View style={styles.imagecontainer}>
        <Image
          source={{ uri: imageURI }}
          style={{ width:"100%",height:"100%", borderRadius: 25, flexWrap:"wrap"}}
          resizeMode="cover"
        />
      </View>
      <View style={styles.content}>
        <Text>{name}</Text>
        <Text>{description}</Text>
      </View>
    </View>
  );
};

Here's a picture for comparison这是一张图片以供比较

在此处输入图片说明

You can use => overflow: 'hidden'您可以使用 => 溢出:'隐藏'

<View style={[styles.imagecontainer, {overflow: 'hidden'}]}>
  <Image
    source={{uri: imageURI}}
    style={{width: '100%', height: '100%', borderRadius: 25, flexWrap: 'wrap'}}
    resizeMode="cover"
  />
</View>;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM