简体   繁体   English

如何在 React 中并排显示两个图标?

[英]How to display two icons side by side in React?

I'm developing an app for a school project and i've been trying to show two icons side by side for a screen (i've been using React for 5 months but i'm still a noob at it)我正在为一个学校项目开发一个应用程序,我一直在尝试在屏幕上并排显示两个图标(我已经使用 React 5 个月了,但我仍然是一个菜鸟)

But they display one over the other, i even tried using Bootstrap columns to make it show them the way i want but i just couldn't do it但是它们显示一个在另一个上,我什至尝试使用 Bootstrap 列让它以我想要的方式显示它们,但我就是做不到

Here's the code这是代码

import { View } from 'react-native';
// import Button from '@mui/material/Button';
import CheckCircle from '@mui/icons-material/CheckCircle'
import styles from '../../App';
import { GiBroom } from 'react-icons/gi';
import { borderRadius } from "@mui/system";
import Container from 'react-bootstrap/Container';
import Row from 'react-bootstrap/Row';
import Col from 'react-bootstrap/Col';

export default function LimpiarCurso(){
    return (
        <Container style={styles.container}>
      <Row>
      <Col><CheckCircle sx={{ fontSize: 200, color: 'white', backgroundColor:'green', display:'inline-block'}} style={{float: 'right'}}/></Col>
      <Col><GiBroom size={200} style={{float: 'right', display: 'inline-block'}}/></Col>
      </Row>
      </Container> 
    )
}

First of all greetings.These are all basic mistakes that were made by freshers.Don't worry.首先问候。这些都是新生犯的基本错误。别担心。 Try putting those Icons inside a {View} tag.尝试将这些图标放在{View}标记中。 And give some styles for View as below.并给出一些 styles 供查看,如下所示。 This works for me.这对我有用。

 import { Image, StyleSheet, Text, View,TouchableOpacity,ScrollView} from 'react-native' import React from 'react'; import { MaterialCommunityIcons,Ionicons,FontAwesome5 } from '@expo/vector-icons'; <View style={{flexDirection:'row',justifyContent:'space-evenly'}}> <TouchableOpacity style={styles.button}> <MaterialCommunityIcons name='message-alert' size={50} color={'#BACAFF'} /> <Text>New Complaint</Text> </TouchableOpacity> <TouchableOpacity style={styles.button}> <MaterialCommunityIcons name='message-alert' size={50} color={'#BACAFF'} /> <Text>Track a Complaint</Text> </TouchableOpacity> </View> The styles for button is button:{ padding:20, backgroundColor:'#fff', elevation:10, shadowColor:'#000', borderRadius:10, alignContent:'center', alignItems:'center' },

输出将是这样的

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM