【问题标题】:How do I make an Image inherit its parent's size? (React Native)如何使图像继承其父级的大小? (反应原生)
【发布时间】:2017-02-08 12:23:26
【问题描述】:

这是我想要的布局:

添加图片时会发生以下情况:

我希望 Image 尊重其父级大小。我该怎么做?

【问题讨论】:

    标签: image reactjs react-native flexbox


    【解决方案1】:

    我最终通过这样做手动计算了图像的宽度:

    screenWidth/7 - margin
    

    这是一个 hack,所以如果有人有正确的做法,我很想听听!

    【讨论】:

      【解决方案2】:

      尝试将图像设置为

           width: null,
           height: null,
           flex: 1
      

      【讨论】:

      • width: null 将宽度设置为 0
      猜你喜欢
      • 1970-01-01
      • 2021-08-14
      • 2011-05-16
      • 1970-01-01
      • 2018-11-01
      • 1970-01-01
      • 2018-07-20
      • 2019-03-25
      • 1970-01-01
      相关资源
      最近更新 更多