React native 除去卡组件中的边框,以响应本机元素

React native 除去卡组件中的边框,以响应本机元素,react-native,React Native,在中,对本机元素进行反应 我试图通过将border设置为0,borderColor设置为transparent来去除边框,但是仍然有一个灰色的轮廓 <Card containerStyle={{borderWidth: 0, borderColor: 'transparent', elevation: 0}} title='HELLO WORLD' image={require('../images/pic2.jpg')}>

在中,对本机元素进行反应

我试图通过将border设置为0,borderColor设置为transparent来去除边框,但是仍然有一个灰色的轮廓

      <Card
        containerStyle={{borderWidth: 0, borderColor: 'transparent', elevation: 0}}
        title='HELLO WORLD'
        image={require('../images/pic2.jpg')}>
        <Text style={{marginBottom: 10}}>
          The idea with React Native Elements is more about component structure than actual design.
        </Text>  
      </Card>  

使用React原生元素的想法更多地是关于组件结构,而不是实际设计。

虽然它可能是方框阴影,但也不是它

在我看到的所有示例中,react native elements的卡片组件都有灰色边框。我建议您构建自己的卡组件。从这样的东西开始,然后按照你想要的方式设计它。这一个有一点阴影,你可以通过传递一个noShadow道具来关闭它

import React from 'react';
import { View, StyleSheet } from 'react-native';

const Card = (props) => {
  let shadowStyle = {
    shadowColor: COLORS.grey3,
    shadowOffset: { width: 0, height: 0 },
    shadowOpacity: .5,
    shadowRadius: 12,
    elevation: 1,
  }
  if (props.noShadow) {
    shadowStyle = {}
  }
  return (
    <View style={[styles.containerStyle, props.style, shadowStyle]}>
      {props.children}
    </View>
  );
};


const styles = StyleSheet.create({
  containerStyle: {
    padding: 10,
    marginHorizontal: 10,
    backgroundColor: COLORS.white,
    borderRadius: 3,
  }
})

export { Card };
然后在渲染方法中

<Card>
<Text>Any content you want to include on the card</Text>
<Text>More content that you want on the card</Text>
</Card>

您想在卡片上包括的任何内容
卡上需要的更多内容

我也遇到了同样的问题,我发现border出现是因为Card元素的高程默认值设置为1

您可以覆盖此选项(对于android):


虽然已经很晚了,但似乎仍有很多人在寻找答案

React原生元素
默认设置了
borderWidth
shadowprops
,因此为了完全删除边框,您需要同时删除
border
shadow


内容
常量样式={
cardCnt:{
边框宽度:0,//删除边框
shadowColor:'rgba(0,0,0,0.0)',//删除iOS的阴影
阴影偏移:{高度:0,宽度:0},
阴影不透明度:0,
阴影半径:0,
标高:0//删除Android的阴影
}
};

设置为屏幕背景色
脏了,但问题解决了。

像这样将
高程设置为0,将
边框颜色设置为
白色

<Card>
<Text>Any content you want to include on the card</Text>
<Text>More content that you want on the card</Text>
</Card>