【问题标题】:When your image is not resizing in RN当您的图像未在 RN 中调整大小时
【发布时间】:2019-07-25 21:11:48
【问题描述】:

我在我的 RN 应用程序中引入了一张图片。这是辛普森一家的形象。当我将宽度和高度设置为 100% 时,图像对于我的模拟器来说变得太大了。我希望它居中并格式化到我的屏幕中心。但是,当我调整百分比时,图像开始被截断(显然)。另一件事,尽管我在代码中说明了图像本身并没有居中(见下文)。你们有什么建议吗?此 png 图像已经在背景图像之上(jpeg)。

<Image
  source={{
   uri:"https://upload.wikimedia.org/wikipedia/en/0/0d/Simpsons_
        FamilyPicture.png"               
     }}
   style={{ width: 100 , height: 120, justifyContent: "center", alignContent: "center" }}
 /> 

【问题讨论】:

    标签: image react-native image-size


    【解决方案1】:

    尝试更改包含的 resizeMode。

    【讨论】:

      【解决方案2】:

      justifyContent 和 alignContent 需要是容器的样式属性。像这样的:

      <View style={{flex: 1, flexDirection: 'column', justifyContent: "center", alignContent: "center"}}>
          <Image
            source={{
             uri:"https://upload.wikimedia.org/wikipedia/en/0/0d/Simpsons_
                  FamilyPicture.png"               
               }}
             style={{ width: 100 , height: 120}}
           /> 
      </View>
      

      【讨论】:

        猜你喜欢
        • 2021-10-02
        • 1970-01-01
        • 2010-12-21
        • 1970-01-01
        • 1970-01-01
        • 2016-12-16
        • 1970-01-01
        • 1970-01-01
        • 2016-03-20
        相关资源
        最近更新 更多