加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

使用resizeMode封面切断图像

发布时间:2020-12-15 09:33:05 所属栏目:百科 来源:网络整理
导读:我有一个图像,当我想使用resizeMode =“cover”使其更大时,图像的一部分被切断.如何解决? render() {return ( View style={styles.container} Image style={styles.imgStyleGoogle} source={{uri: 'my.png'}} /View )}const styles = StyleSheet.create({ c
我有一个图像,当我想使用resizeMode =“cover”使其更大时,图像的一部分被切断.如何解决?

render() {
return (
 <View style={styles.container}>

        <Image
          style={styles.imgStyleGoogle}
          source={{uri: 'my.png'}}
        />
<View>
    )
}

const styles = StyleSheet.create({
  container: {
        flex: 1,alignItems:  'center',marginLeft: ratio * 5,marginRight: ratio * 5,},imgStyleGoogle: {
        flex: 1,height: ratio*25,width: ratio*100,resizeMode:'cover',}
})

这是图片的示例:

enter image description here

解决方法

我找到了解决方案,问题出在flex:1,在Image中,我从imgStyleGoogle中删除了它并更改了resizeMode:’contains’,并且没有更多的图像被切断.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读