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

How can I make my text just below the image without disturbing buttons and image?

How can I make my text just below the image without disturbing buttons and images? I want to make text just below the image so I tried doing margin-top, and top but then it disturbs the buttons, and the image and text are sticking to each other I also tried to put text into a view so I same problem Can you help me to do that? is there a different way to get the same UI but with a different styles

import { StyleSheet, Text, View, Image } from 'react-native'
import React from 'react'

const App = () => {

  return (
    <View style={styles.container}>
      {
        userData.map((data) => {
          return <View key={data._id} style={styles.userSection}>
            <View style={styles.imageContainer}>
              <Image
                style={styles.image}
                source={{ uri: data.img }}
                resizeMode="contain"
                overflow="hidden"
              />
            </View>
            <Text style={styles.text}> Text Here! </Text>
          </View>
        })
      }
      <Text style={styles.btn1}>Submit</Text>
      <Text style={styles.btn2}>Submit</Text>
    </View>
  )

}

export default App

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
    backgroundColor: 'black'
  },
  userSection: {
    flexDirection: 'column',
    alignItems: 'center',
    bottom: '50%'
  },
  imageContainer: {
    width: 140,
    height: 140,
    borderRadius: 70,
    overflow: 'hidden',
    marginLeft: '5%',
    top: '80%'
  },
  image: {
    width: '100%',
    height: '100%',
  },
  text: {
    fontSize: 20,
    fontWeight: 'bold',
    color: 'white',
    marginTop: '60%',
  },
  btn1: {
    width: '80%',
    backgroundColor: 'white',
    borderRadius: 10,
    borderColor: 'white',
    borderWidth: 2,
    fontSize: 25,
    color: 'black',
    textAlign: 'center',
    paddingVertical: 15,
    marginVertical: 10,
    fontWeight: "bold",
    top: '5%'
  },
  btn2: {
    width: '80%',
    backgroundColor: 'white',
    borderRadius: 10,
    borderColor: 'white',
    borderWidth: 1,
    fontSize: 25,
    color: 'black',
    textAlign: 'center',
    paddingVertical: 15,
    marginVertical: 10,
    fontWeight: "bold",
    top: '5%'
  }
});

>Solution :

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

A good approach would be flexbox layout:

userSection: {
    flexDirection: 'column',
    alignItems: 'center',
    flex: 1,
    justifyContent: 'center',
}
text: {
    fontSize: 20,
    fontWeight: 'bold',
    color: 'white',
    marginTop: 10,
}
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