卡片视图背景颜色影响阴影颜色 [英] Card View background color affects shadow color

查看:52
本文介绍了卡片视图背景颜色影响阴影颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的卡片视图设置如下:

I have my Card View set up like this:

android:layout_marginTop="2dp"
android:layout_marginLeft="6dp"
android:layout_marginRight="6dp"
card_view:cardCornerRadius="2dp"
card_view:cardElevation="6dp"
card_view:cardUseCompatPadding="true"
card_view:contentPadding="10p"

如果没有背景色,我的卡片视图看起来很完美:

Without a background color my Card View looks perfect like this:

但是,当我添加简单属性时:

However, when I add the simple property:

card_view:cardBackgroundColor="#xxxxxxxx"

阴影在颜色、透明度、模糊等方面发生了显着变化

the shadows change significantly in terms of color, transparency, blur etc.

我该如何解决这个问题?我尝试使用 RelativeLayout 作为背景并更改那里的颜色,所以它不会影响阴影......但会影响圆角.

How might I go about fixing this? I tried using a RelativeLayout as the background and changing the color there, so it wouldn't affect the shadows... but that affected the rounded corners.

有什么想法吗?感谢您的帮助!

Any ideas? Thanks for the help!

推荐答案

我遇到了完全相同的问题,并通过删除我的十六进制代码的 alpha 部分来解决它.

I ran into the exact same problem and solved it by removing the alpha portion of my hex code.

示例:#AA333333 移除 AA.当然,使用不需要 alpha 的十六进制颜色.

Example: #AA333333 removing the AA. Of course use the hex color that you need without the alpha.

这篇关于卡片视图背景颜色影响阴影颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆