UPDATE
添加CSS屬性elevation: 1
呈現陰影在Android中沒有安裝任何第三方庫什麼。查看其他答案。
-
一種方式來獲得Android的陰影是從自述安裝react-native-shadow
例子:
import React, {Component} from 'react' import {
StyleSheet,
View,
Text,
ScrollView,
Image,
TouchableHighlight } from 'react-native'
import {BoxShadow} from 'react-native-shadow'
export default class VideoCell extends Component {
render =() => {
const shadowOpt = {
width:160,
height:170,
color:"#000",
border:2,
radius:3,
opacity:0.2,
x:0,
y:3,
style:{marginVertical:5}
}
return (
<BoxShadow setting={shadowOpt}>
<TouchableHighlight style={{
position:"relative",
width: 160,
height: 170,
backgroundColor: "#fff",
borderRadius:3,
// marginVertical:5,
overflow:"hidden"}}>
…………………………
</TouchableHighlight>
</BoxShadow>
)
}
}
添加CSS屬性'高度:1'在Android中呈現陰影,無需安裝任何第三方庫。我使用React Native 0.52 – Guy