Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React Native Half oval on View

I'm new to react-native, I want to create a view with a half oval in the bottom. I can achieve this problem using CSS, but I cannot use it in react-native as it only accepts the single number.

Example result

enter image description here

.halfOval { 
    background-color: #a0C580;
    width: 400px;
    height: 20px;
    border-radius:  0 0 50% 50% / 0 0 100% 100%;
}
<div class="halfOval"></div>
like image 587
user2914177 Avatar asked Nov 27 '25 23:11

user2914177


1 Answers

One solution I can say is to create a semicircle and scale it based on your device resolution. Sample code is given below

<View style={styles.ovalBgH}> 
    <View style={styles.ovalBg}>
    </View>
</View>

Stylesheet code

ovalBgH:{
    overflow: 'hidden', 
    width : 50, 
    height:25, 
    position : 'absolute', 
    borderBottomEndRadius:25,
    borderBottomLeftRadius:25,
    left:-25,
    top:10,
    backgroundColor:'transparent',
    transform: [
    {scaleX: 7}
    ]
},
ovalBg:{
    backgroundColor: '#a0c580',
    width : 50, height:50,
    transform: [
    {scaleX: 7}
    ]
}

Screenshot is given below enter image description here

like image 51
Ajith Avatar answered Nov 30 '25 12:11

Ajith



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!