在React Native中连续放置3个图像图标

问题描述 投票:0回答:2

对于社交媒体登录,我想放置社交媒体图标,如下图所示。如何获得enter image description here

facebook-login social google-login twitter-login
2个回答
0
投票

您必须使用flexDirection设置为row来定义容器。

render() {
  return (

       <View style={styles.containertest}>
           <Image
                  source={Icon}
                  style={styles.inputIcon}
                  resizeMode="contain"
                />
     <Image
                  source={Icon}
                  style={styles.inputIcon}
                  resizeMode="contain"
                />

<Image
                  source={Icon}
                  style={styles.inputIcon}
                  resizeMode="contain"
                />
    </View>


  );
}


const styles = StyleSheet.create({
  container: {
    flex: 1,
    flexDirection: 'row',
    justifyContent: 'space-between'
  },
  button: {
    backgroundColor: 'green',
    width: '40%',
    height: 40
  },
  inputIcon: {
    width: 35,
    height: 35,
    marginBottom: 5

  },
});

Image内你可以添加你想要在屏幕上显示的任何图像source。 您可以根据需要进行进一步的更改。 希望能帮助到你 !


0
投票

试试这个:

<View style={{ height: 100, alignItems: 'center', justifyContent: 'center' }}>
            <View style={{ flexDirection: 'row' }}>
                    <TouchableOpacity onPress={() => { }}>
                        <MaterialCommunityIcons style={{ padding: 3 }} name="facebook" size={15} color="white" />
                    </TouchableOpacity>

                    <TouchableOpacity onPress={() => { }}>
                        <MaterialCommunityIcons style={{ padding: 3 }} name="google" size={15} color="white" />
                    </TouchableOpacity>

                    <TouchableOpacity onPress={() => { }}>
                        <MaterialCommunityIcons style={{ padding: 3 }} name="twitter" size={15} color="white" />
                    </TouchableOpacity>
            </View>
        </View>

使用MaterialCommunityIcons作为图标。如果你在Expo上就做:

import { MaterialCommunityIcons } from '@expo/vector-icons';
© www.soinside.com 2019 - 2024. All rights reserved.