How do I render a shadow on a View
? I've tried many combinations of shadowColor
, shadowOffset
, shadowOpacity
, and shadowRadius
, which seem to do nothing. I am sure the style is applied correctly, since other attributes I've set work.
Javascript – How to render a shadow
javascriptreact-native
Best Answer
I am using React-Native 0.40 and below code works for me both on IOS and Android.
(Android-only) Sets the elevation of a view, using Android's underlying elevation API. This adds a drop shadow to the item and affects z-order for overlapping views. Only supported on Android 5.0+, has no effect on earlier versions.
Tested on iPhone.
Edit
Comment from @ James. Thanks.
Note: For those on android, the backgroundColor is critical. I was using View as a container for another element and couldn't get a shadow until I specified a background color.