Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React Native border radius rendering

When you add a border radius to a border in CSS the border will gradually decline in width around the border radius, as you can see in this example:

.example {
  width: 100px;
  height: 50px;
  background: #000;
  border-bottom: 4px solid red;
  border-bottom-right-radius: 20px;
}
<div class="example"></div>

I am trying to do the same within React Native, however React Native seems to cut off the last bit:

React native example

As you can see it doesn't taper off the border along the radius.

What would be the best approach to get the border to taper off like it does in web engines?

like image 886
Melvin Koopmans Avatar asked Feb 06 '19 10:02

Melvin Koopmans


People also ask

How do you make a 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 make an image circular in React Native?

To create perfectly round images in React Native, just give the borderRadius property a very high value. The code: // App.

How to set border radius of image in React Native?

We will set the border radius of the Image using StyleSheet element borderRadius. Step 1: First create the new reactive project. Step 2 : Create the "images" folder inside the react native project structure and refer the below screenshot. Step 4: Open App.js File in your favorite code editor and erase all code and follow this tutorial.

How to create border style in React Native with syntax?

How we can create Border Style in React Native with Syntax and Examples? 1. Creating borders using the color, width and style properties To set a border, you must first set borderWidth. 2. Using border-radius to create shapes

How to make corner rounded in React Native?

To make corner rounded, React Native provide below props and we are going to learn with example. React Native provide borderRadius prop to make all corners rounded and borderRadius prop only accept number between 1 to 100 or if you put more then 100 value it should same output of 100 value let understand with example.

How to create a react native app with images?

Step 1: First create the new reactive project. Step 2 : Create the "images" folder inside the react native project structure and refer the below screenshot. Step 4: Open App.js File in your favorite code editor and erase all code and follow this tutorial.


Video Answer


1 Answers

Faced the same problem and couldn't find a solution with borderRadius styles. Solved by using two Views with different height. But not sure whether is it a good approach. Check snack for a working sample.

view1:{        
    width:200,
    height:100,
    backgroundColor:'red',
    borderRadius:10,    
    alignItems:'center'
  },

view2:{
    alignItems:'center',
    justifyContent:'center',
    width:200,
    height:95,
    backgroundColor:'white',
    borderBottomEndRadius:10,
    borderBottomStartRadius:10
  }

enter image description here

like image 131
Dinith Minura Avatar answered Oct 21 '22 21:10

Dinith Minura