i’m trying to make a grid using react native that’s responsive to multiple screen sizes but having troubles drawing the lines in (the sides of the box can’t have a stroke).
this is a small snippet:
<View style={styles.boxContainer}>
<View style={styles.box}>
<Text style={styles.boxText}> X </Text>
</View>
<View style={styles.box}>
<Text style={styles.boxText}> O </Text>
</View>
<View style={styles.box}>
<Text style={styles.boxText}> X </Text>
</View>
<View style={styles.box}>
<Text style={styles.boxText}> X </Text>
</View>
<View style={styles.box}>
<Text style={styles.boxText}> O </Text>
</View>
<View style={styles.box}>
<Text style={styles.boxText}> O </Text>
</View>
<View style={styles.box}>
<Text style={styles.boxText}> X </Text>
</View>
<View style={styles.box}>
<Text style={styles.boxText}> X </Text>
</View>
<View style={styles.box}>
<Text style={styles.boxText}> O </Text>
</View>
</View>
</SafeAreaView>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
alignItems: 'center',
justifyContent: 'center',
},
box: {
alignItems: 'center',
width: DeviceWidth*0.3,
height: DeviceWidth*0.3,
},
boxContainer: {
flexDirection: 'row',
flexWrap: 'wrap',
justifyContent: 'center',
marginRight: DeviceWidth*0.05,
marginLeft: DeviceWidth*0.05,
},
i’ve tried doing a border but it covers the entire thing and i’m unsure how to clear the lines on the side 🙁 i’ve also tried adding a background color to my container and attempting to add space between the boxes but couldnt figure out how to make the background look similar in size..
4
Answers
How about this,
result:
Try breaking the grid into 3 rows and 3 columns (boxes). Create styles for each individual column/row demo: