Reactjs 反应如何将图像放置在一行中

Reactjs 反应如何将图像放置在一行中,reactjs,react-native,Reactjs,React Native,嘿,我正努力把两张图像放在彼此相邻的位置,它们之间留有一些空间 经过长时间的搜索,我得到的最接近的结果是: 正如你所看到的,图像之间没有空间,我试图用marginRight或paddingRight来改变这一点,但似乎没有任何改变。。 这是我的密码: let stylereg_na = { alignItems: "center", flex: 1, height: hp('7%'), width: wp('7%')}; let stylereg_eu = {height:

嘿,我正努力把两张图像放在彼此相邻的位置,它们之间留有一些空间 经过长时间的搜索,我得到的最接近的结果是:

正如你所看到的,图像之间没有空间,我试图用marginRight或paddingRight来改变这一点,但似乎没有任何改变。。 这是我的密码:

let stylereg_na = { alignItems: "center", flex: 1, height: hp('7%'), width: wp('7%')};
let stylereg_eu = {height: hp('10%'), width: wp('9%')};

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

<View style={{flexDirection: "row", justifyContent: "space-between"}}>

<View style={{alignItems: "center", flex: 1, paddingTop: 15, paddingBottom : 15}}>
<img style={stylereg_na} src ={na}>
</View>

<View style={{ alignItems: "center", paddingTop: 15, paddingBottom : 15 }}>
<img style={stylereg_eu} src ={eu}/>
</View>

</View>
</View>
);

const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#D8D8D8',
alignItems: 'center',
justifyContent: 'center',
},
});
let stylereg_na={alignItems:“center”,flex:1,高度:hp('7%”),宽度:wp('7%”);
设stylereg_eu={高度:hp('10%),宽度:wp('9%)};
返回(
);
const styles=StyleSheet.create({
容器:{
弹性:1,
背景颜色:“#D8D8D8”,
对齐项目:“居中”,
为内容辩护:“中心”,
},
});

确保您正在使用React Native提供的
图像组件。此外,您的父容器正在使用
调整内容
之间的间距
,因此只要您希望flex为您计算出间距,就不必使用填充或边距

import React from "react";
import { View, Image } from "react-native";

const ViewBoxesWithColorAndText = () => {
let stylereg_na = { height: 50, width: 50};
let stylereg_eu = { height: 50, width: 50};

  return (
    <View style={{flexDirection: "row", justifyContent: "space-between"}}>

      <View style={{alignItems: "center", flex: 1, paddingTop: 15, paddingBottom : 15}}>
        <Image style={stylereg_na} source={na} />
      </View>

      <View style={{ alignItems: "center", paddingTop: 15, paddingBottom : 15 }}>
        <Image style={stylereg_eu} source={eu}/>
      </View>

    </View>
  );
};

export default ViewBoxesWithColorAndText;

从“React”导入React;
从“react native”导入{View,Image};
const ViewBoxesWithColorAndText=()=>{
设stylereg_na={高度:50,宽度:50};
设stylereg_eu={高度:50,宽度:50};
返回(
);
};
导出带有颜色和文本的默认ViewBox;

添加
填充左:15
paddingRight:15
到样式

尝试将
padding:15
添加到包装图像的视图中,如下所示

  <View style={{padding: 15}}>
        <Image style={stylereg_na} source={na} />
      </View>


即使使用了您的代码,图像之间也没有空间……我在本地测试了此功能,并确认它确实有效。你确定你的图像不比容器大吗?我试过了,出于某种原因,它没有任何作用。你能在零食上分享你的代码吗<代码>https://snack.expo.io/