Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React Native border radius makes outline

Tags:

I would like to make the circle view by using react-native.

Here what I did:

circle: {     position: 'absolute',     borderWidth: 10,     borderColor: '#fff',     top: 20,     left: 30,     width: 150,     height: 150,     borderRadius: 150 / 2,     backgroundColor: '#ED1D27',   } 

And view

<View style={styles.circle}></View> 

The result is:

enter image description here

There is and outline rounded the circle.

I don't want that outline. I checked by remove the border radius and it has no outline like below:

enter image description here

I have no idea for this issue, please help me...

like image 225
Luc Avatar asked May 03 '17 09:05

Luc


People also ask

How do you set border radius in React Native?

Border Radius in React NativeThe borderRadius property can be set as the style attribute to any element. It takes a value in pixels and assigns that value to the overall border radius of that UI element. By default, the border radius of any element is 0 if you haven't added that style attribute to that element.

How do I give border width in React Native?

To set border around view component in react native we have to use borderWidth and borderColor style prop. Using the borderWidth prop we would define the border width in pixels. The borderWidth prop Number type value. The higher value we would pass the thicker border would be.


1 Answers

So I am not entirely sure why it gives that very small red border with your current rule. It could be an actual bug. Regardless if I understand correctly, you want a circle without that small red border. You can achieve that by removing your border property:

position: 'absolute', top: 20, left: 30, width: 150, height: 150, borderRadius: 150 / 2, backgroundColor: '#ED1D27', 

Resulting in:

enter image description here

If you do want a border, a potential workaround could be:

inner: {   position: 'relative',   width: 150,   height: 150,   borderRadius: 150 / 2,   backgroundColor: '#ED1D27', }, outter:{   position: 'absolute',   paddingTop:10,   paddingLeft:10,   top: 20,   left: 30,   width: 170,   height: 170,   borderRadius: 160 / 2,   backgroundColor: '#000', }, 

With a view heirarchy like:

  <View style={styles.container}>     <View style={styles.outter}>       <View style={styles.inner}></View>     </View>   </View> 

Resulting in:

enter image description here

like image 160
klvs Avatar answered Sep 22 '22 18:09

klvs