admin管理员组文章数量:1334188
Is there any way to render shadow as in web in react native, using elevation most of the times does not fits all the needs and shadow props only work for IOS, is there any react native builtin way to handle shadow props in android, if no then please suggest good light weight packages for shadow props must be easy to use. Thank you
Is there any way to render shadow as in web in react native, using elevation most of the times does not fits all the needs and shadow props only work for IOS, is there any react native builtin way to handle shadow props in android, if no then please suggest good light weight packages for shadow props must be easy to use. Thank you
Share Improve this question asked Sep 25, 2018 at 14:24 Ammar TariqAmmar Tariq 8472 gold badges14 silver badges30 bronze badges5 Answers
Reset to default 2Shadow properties in react-native applies only on iOS. For Android you should set elevation property in your view style.
You can use my react-native-simple-shadow-view
- This enables almost identical shadow in Android as in iOS
- No need to use elevation, works with the same shadow parameters of iOS (shadowColor, shadowOpacity, shadowRadius, offset, etc.) so you don't need to write platform specific shadow styles
- Can be used with semi-transparent views
- Supported in android 18 and up
It is possible to use this code to make shadow in android:
const styles = StyleSheet.create({
myShadow: {
backgroundColor: "red",
//flex: 1,
height:50,
borderRadius: 10,
shadowColor: '#000',
shadowOpacity: 0.8,
shadowRadius: 4,
elevation: 4,
},
});
inside the render you can use like this:
render() {
<View style={styles.myShadow}/>
}
For android, the elevation property does not work very well, I remand this lib, the style works the same as on ios: react-native-shadow-view
Best way to provide shadow in Android and Ios both application in react native
shadowColor: "#000",
shadowOffset: {
width: 0,
height: 2,
},
shadowOpacity: 0.25,
shadowRadius: 3.84,
elevation: 5,
Link : https://ethercreative.github.io/react-native-shadow-generator/本文标签: javascriptReactnative shadow props for androidStack Overflow
版权声明:本文标题:javascript - React-native shadow props for android - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742310997a2450869.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论