Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React native elevation - shadow appears in boarder

I tried to add a shadow using the following code:

<View style={{alignItems: 'center'}}>
    <View
      style={{
        width: '95%',
        borderWidth: 1,
        elevation: 5,
        shadowColor: 'black',
        shadowRadius: 10,
      }}>
      <TextInput
        style={{
          borderColor: colors.primary,
          borderWidth: 1,
          color: 'black',
          fontSize: 18,
          height: 64,
        }}
        onChange={input => this.onChange(input.nativeEvent.text)}
        value={this.state.input}
      />
      <View>{this.state.results}</View>
  </View>
</View>

Somehow, the elevation effects the width and hight of the inner "box":

When I use elevation: 10:

enter image description here

When I use elevation: 0:

enter image description here

How can I set the shadow to be outside the boarder?

like image 978
JaRoMaster Avatar asked Oct 24 '25 16:10

JaRoMaster


1 Answers

After a lot of testing, I figured out the problem was that there's no backgroundColor applied to the View with the shadow.

Now the shadow seems to work as expected

like image 180
JaRoMaster Avatar answered Oct 26 '25 05:10

JaRoMaster



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!