从 ImageCardView 中删除背景 [英] Remove background from ImageCardView
问题描述
我开始使用新的 android.support.v17.leanback
库,但在设计 ImageCardView
样式时遇到了一些麻烦.
I started using new android.support.v17.leanback
library and have some trouble in styling ImageCardView
.
我正在将 ImageCardView
上的图像更改为具有不同的形状,因此我想删除在 ListRow
中使用卡片时自动生成的背景和阴影,例如.如果我留下阴影,我的卡片看起来很奇怪,因为阴影和背景显示为卡片是方形的.
I am changing the image on ImageCardView
to have a different shape so I would like to remove background and shadow which are automatically generated when using the card in ListRow
for example. If I leave the shadow, my card looks weird because shadow and background are showing like the card is square.
我尝试为所有元素设置不同的背景,但它不起作用.如果我设置正常背景颜色(绿色、蓝色等),图像或信息区域的背景会发生变化,但如果我设置透明背景,则可以看到另一个包裹整个卡片的背景.
I've tried to set the different background to all the elements but it doesn't work. If I set the normal background color (green, blue, etc), the background of the image or info area would change but if I set the transparent background, another background which wraps the whole card would be visible.
任何想法如何解决这个问题?
Any ideas how to solve this issue?
推荐答案
您的问题与 CardView
本身无关,而与演示者有关.将此行放在您的 RowPresenter
/ListRowPresenter
:
Your problem is not about the CardView
itself, it's about your presenter. Put this line your RowPresenter
/ListRowPresenter
:
listRowPresenter.setShadowEnabled(false);
此外,在这篇 Medium 文章中 你可以看到如何让你CardView
循环.它展示了如何在行未聚焦时移除阴影,覆盖 isUsingDefaultListSelectEffect()
方法始终为 false
.
Furthermore, in this Medium article you can see how to make you CardView
circular. And where it shows how to remove the shadow when the row is not focused, overriding the isUsingDefaultListSelectEffect()
method to be always false
.
这篇关于从 ImageCardView 中删除背景的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!