Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

space evenly based on icon rather than text

I am trying to space these two bodies together evenly across the device. While implementing it the way I currently am, the space-evenly renders but it spaces it by the words. I would like the space-evenly to base its spacing on the icon instead.

I have provided a demo here as well as the code below.

  render() {
    return (
      <View
        style={{
          flexDirection: 'row',
          top: 75,
          justifyContent: 'space-evenly',
        }}>
        <View style={{ justifyContent: 'center', alignItems: 'center' }}>
          <MaterialCommunityIcons
            name="map-marker-radius-outline"
            color="black"
            size={50}>
          </MaterialCommunityIcons>

          <Text style={{ fontSize: 15 }}>
            WORD
          </Text>
        </View>

        <View style={{ justifyContent: 'center', alignItems: 'center' }}>
          <MaterialCommunityIcons
            name="star-outline"
            color="black"
            size={50}>
          </MaterialCommunityIcons>

          <Text style={{ fontSize: 15 }}>
              WORD WORD
           </Text>
        </View>
      </View>
    );
  }
}

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

if I understand your issue right, you need both elements to take the same space across the available width. For that, you have to add flex: 1 to both of your inner views

<View style={{ justifyContent: 'center', alignItems: 'center', flex: 1 }}>
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading