How to center a view inside another view in React Native?
You should center both, outer and inner circles, like this:
const styles = StyleSheet.create({
container: {
flex: 1,
flexDirection: 'column',
justifyContent: 'center',
alignItems: 'center',
backgroundColor: 'yellow',
},
outerCircle: {
backgroundColor: 'blue',
width: 100,
height: 100,
borderRadius: 100/2,
justifyContent: 'center',
alignItems: 'center',
},
innerCircle: {
backgroundColor: 'red',
width: 80,
height: 80,
borderRadius: 80/2,
justifyContent: 'center',
alignItems: 'center',
}
});
make things center by these two followings
justifyContent: 'center', alignItems: 'center',
You are already centering in the container. Follow the same for outerCircle as well.
outerCircle: {
backgroundColor: 'blue',
width: 100,
height: 100,
borderRadius: 100/2,
justifyContent: 'center',
alignItems: 'center'
},