ios - 内容上的 native 基本弯曲方向不起作用

标签 ios react-native native-base

我想并排显示两个图像,而不是在另一个图像的底部显示。这是我的代码:

 <Content style={{flexDirection: 'row', flexWrap: 'wrap'}}>
     <Image
        key={data[0]['id']}
         source={{ uri: data[0]['image']['url']}}
         style={{
           width: Dimensions.get('window').width * 0.2,
           height: 120,
           }}
      />
     <Image
       key={data[1]['id']}
       source={{ uri: data[1]['image']['url']}}
       style={{
         width: Dimensions.get('window').width * 0.2,
         height: 120,
         }}
     />           
 </Content>

但它没有按预期工作。我在这里缺少什么?

最佳答案

Avoid flexWrap and use flex.

<Content style={{flexDirection: 'row', flex:1}}> // Note flex.
  <Image
     key={data[0]['id']}
     source={{ uri: data[0]['image']['url']}}
     style={{
       flex: 0.5, // Give the 50% of the width to this image.
       height: 120,
       }}
   />
  <Image
    key={data[1]['id']}
    source={{ uri: data[1]['image']['url']}}
    style={{
      flex: 0.5, // Give the 50% of the width to this image.
      height: 120,
     }}
 />           

I haven't really tested this code. But it should work fine. Thanks.

关于ios - 内容上的 native 基本弯曲方向不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43580806/

相关文章:

android - react-native-audio-toolkit录制错误

reactjs - 可以在单个 TextInput 中保存多个值吗?

reactjs - NativeBase : Generate Columns in Row

javascript - 使用最新的 react native 版本时出现 createBottomTabNavigator 和无法识别的字体系列问题

ios - 按 dateTimeString 属性对 NSMutableArray 对象进行排序

ios - 偏移不会在onTapGesture之后重置-SwiftUI

react-native - 我们可以在 native react 中更改下拉标签的颜色吗

reactjs - 找不到模块 'babel-preset-react'

ios - Xamarin、MVVM交叉和崩溃报告

ios - 在 Gamecenter 中导出成就