React native 反应本族语、儿童和#x27;s宽度的百分比

React native 反应本族语、儿童和#x27;s宽度的百分比,react-native,React Native,这是我的密码。我希望产品视图占其父视图宽度的90%。但是,以下设置不起作用 …知道如何在不使用维度的情况下实现它吗 return ( <LazyloadScrollView style={styles.container} contentContainerStyle={styles.content} name="scrollImage" > {list.map((pro

这是我的密码。我希望产品视图占其父视图宽度的90%。但是,以下设置不起作用

…知道如何在不使用维度的情况下实现它吗

   return (
        <LazyloadScrollView
            style={styles.container}
            contentContainerStyle={styles.content}
            name="scrollImage" >
          {list.map((product, i) => <View key={i} style={styles.product}>
            <LazyloadImage
                host="scrollImage"
                style={styles.image}
                source={image}
                animation={false}>
              <View style={styles.id}>
                <Text style={styles.idText}>{product.id}</Text>
              </View>
            </LazyloadImage>
          </View>)
          }
        </LazyloadScrollView>
    );
  }
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: '#ffffff'
  },
  content: {
    paddingTop: 20,
    justifyContent: 'center',
    alignItems: 'center',
      backgroundColor: '#eee'
  },
    product: {
        flex: 0.9,
        marginTop: 5,
        flexDirection: 'row',
        alignItems: 'center',
        backgroundColor: '#FFFFFF'
    },
返回(
{list.map((产品,i)=>
{product.id}
)
}
);
}
}
const styles=StyleSheet.create({
容器:{
弹性:1,
背景颜色:“#ffffff”
},
内容:{
paddingTop:20,
为内容辩护:“中心”,
对齐项目:“居中”,
背景颜色:“#eee”
},
产品:{
弹性系数:0.9,
玛金托普:5,
flexDirection:'行',
对齐项目:“居中”,
背景颜色:“#FFFFFF”
},

为什么不使用
维度
?它将使您的应用程序能够响应

如果不想使用尺寸标注,请尝试容器及其子容器中的一些样式设置,例如,使用填充使其全宽

container: {
    backgroundColor: '#ffffff',
    alignSelf: 'stretch',
    padding: 30
  }
我不知道它是否有效,因为您必须发布代码的其余部分来测试它,但在使其有效之前,请继续使用style和flex属性,这不会花费太长时间

顺便说一句,重游世界总是好的


不确定
LazyLoadImage
但是对于
Image
你必须指定
width:null
height:null
如果你想使用
flex
实际上我想要的是它的父对象的80%宽度,而不是图像