从ImageCardView删除背景 [英] Remove background from ImageCardView

查看:135
本文介绍了从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);

此外,在此中型文章可以看到如何使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屋!

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