Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I render a shadow?

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.

like image 758
user2503846 Avatar asked Mar 28 '15 22:03

user2503846


People also ask

How do I render a shadow in blender?

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.

How do I render a shadow in Maya?

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.

How do you show shadows in planning?

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.


1 Answers

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.

enter image description here

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.

like image 136
Ashok R Avatar answered Sep 22 '22 12:09

Ashok R