简体   繁体   English

React Native图像阴影未显示在视图中

[英]React Native image shadow is not showing up on view

I have a png image with shadow in it. 我有一个带有阴影的png图像。

在此处输入图片说明

But when I'm trying to add it in react native, the shadow is not coming up. 但是,当我尝试将其添加到本地响应中时,阴影不会出现。

在此处输入图片说明

I've tried to give that view a shadow. 我试图给那个看法加阴影。 I was able to add top shadow in IOS but Android doesn't support top shadow. 我能够在IOS中添加顶部阴影,但Android不支持顶部阴影。

Is there any way to achieve top shadow in android or any way to show complete png file with shadow. 有没有办法在android中实现顶部阴影或以阴影显示完整的png文件。

I am using React Native 0.55.4 and Android 8.0.0 我正在使用React Native 0.55.4和Android 8.0.0

Thanks in advance. 提前致谢。

For android use property elevation: 1 or react-native-shadow react-native-shadow working example 对于android使用属性elevation: 1react-native-shadow 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:3,
            y:3,

            style:{marginVertical:5}
        }

        return (
          <View style={{flex:1}}>
            <BoxShadow setting={shadowOpt}>
                <TouchableHighlight style={{
                  marginTop:10,
                    position:"relative",
                    width: 160,
                    height: 170,
                    backgroundColor: "#fff",
                    borderRadius:3,
                    // marginVertical:5,
                    overflow:"hidden"}}>
                 <Text>Wnand</Text>
                </TouchableHighlight>
            </BoxShadow>
            </View>
        )
    }
}

I like to use the react-native-shadow to create shadow views on Android. 我喜欢使用react-native-shadow在Android上创建阴影视图。

The component will be something like: 该组件将类似于:

const shadowOpt = {
    width:100,
    height:100,
    color:"#000",
    border:2,
    radius:3,
    opacity:0.2,
    x:0,
    y:3,
    style:{marginVertical:5}
}
<Shadow setting={shadowOpt}>
  ... your view here
</Shadow>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM