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.
One quick way to achieve this using Blender Internal is to select the plane and add a new material, in the material settings under shadow, enable Shadows Only. Next, you can optionally enable transparency, use Z Transparency and use the alpha slider to control the strength/darkness of the shadow.
Select the light for which you want to produce a shadow. In the Shadows section of the light's Attribute Editor, turn on Use Depth Map Shadows. Select the surface on which you want to cast a shadow. In the Render Stats section of the surface's Attribute Editor, turn on Casts Shadows.
To create a Sun Angle and display a shadow in plan viewSelect CAD> Lines> Sun Angle and click in the drawing area where you want the Sun Angle to be displayed. In the Sun Angle Specification dialog that appears, specify the Sun Angle's information.
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.
class MainApp extends Component { render() { return ( <View style={styles.container}> <View elevation={5} style={styles.buttonContainer}> <Text style={styles.textStyle}>Shadow Applied</Text> </View> </View> ); } } const styles = StyleSheet.create({ container: { flex: 1, justifyContent: 'center', alignItems: 'center', backgroundColor: '#FFFFFF' }, textStyle: { color: '#FFFFFF' }, buttonContainer: { backgroundColor: '#2E9298', borderRadius: 10, padding: 10, shadowColor: '#000000', shadowOffset: { width: 0, height: 3 }, shadowRadius: 5, shadowOpacity: 1.0 } })
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With