[英]react native default backgroundcolor
I want to change my card color according to the app's global background color.我想根据应用程序的全局背景颜色更改我的卡片颜色。 Because I want to disappear the background color that a marked with white.
因为我想消失用白色标记的背景颜色。 I tried the backgroundColor with #F2F2F2 #eee and #ffffff but always a little difference exist.
我用#F2F2F2 #eee 和#ffffff 尝试了backgroundColor,但总是存在一些差异。 So how can i change de back ground color for same as the default backgroundColor.
那么如何将背景颜色更改为与默认背景颜色相同。
Here is my code:这是我的代码:
function Card(props) {
return (
<View style={styles.box}>
<View style={styles.inner}>{props.children}</View>
</View>
);
}
const styles = StyleSheet.create({
box: {
width: "45%",
height: "50%",
padding: 5,
shadowColor: "#000",
shadowOffset: {
width: 0,
height: 6,
},
shadowOpacity: 0.39,
shadowRadius: 8.3,
backgroundColor: "#ffffff",
elevation: 13,
margin: 5,
},
inner: {
flex: 1,
backgroundColor: "transparent",
alignItems: "center",
justifyContent: "center",
},
});
If i don't apply the shadow its background is good but.如果我不应用阴影,它的背景很好但是。 when i applied shadow to my card component always backgroud color of my app and card component are different
当我将阴影应用到我的卡片组件时,我的应用程序和卡片组件的背景颜色总是不同
App photo without shadow: (That is the back ground color that i want)没有阴影的应用照片:(这是我想要的背景颜色)
App photo with shadow: (I want to remove the white part of my card. When i applied shadow always some color difference exist.)带阴影的应用照片:(我想删除卡片的白色部分。当我应用阴影时,总是存在一些色差。)
You can get image with the shadow underneath by applying shadow properties and backgroundColor
( #ffffff
) to the first parent of the <Image/>
.您可以通过将阴影属性和
backgroundColor
( #ffffff
) 应用到<Image/>
的第一个父项来获取带有阴影的图像。
By doing so, you'll not have white border-ish background around image.通过这样做,您将不会在图像周围有白色边框背景。
I've created example Expo — Image Card With Shadow我创建了示例Expo — 带阴影的图像卡
I think your question is very similiar to this one.我认为您的问题与此问题非常相似。
Also if you try to find out a Color of a HTML-Element in the Browser, you can easily use ie the Chrome DevTools and inspect the corresponding Element.此外,如果您尝试在浏览器中找出 HTML 元素的颜色,您可以轻松地使用Chrome DevTools并检查相应的元素。
Hope this brings you to the right track.希望这能让您走上正确的道路。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.