从 ImageCardView 中移除背景
Remove background from ImageCardView
我开始使用新的 android.support.v17.leanback
库,但在样式 ImageCardView
方面遇到了一些问题。
我正在将 ImageCardView
上的图像更改为不同的形状,因此我想删除在 ListRow
中使用卡片时自动生成的背景和阴影。如果我离开阴影,我的名片看起来很奇怪,因为显示的阴影和背景就像名片是正方形的。
我试过为所有元素设置不同的背景,但它不起作用。如果我设置正常背景颜色(绿色、蓝色等),图像或信息区域的背景会发生变化,但如果我设置透明背景,则可以看到另一个包裹整个卡片的背景。
有解决这个问题的想法吗?
根据这个,你不能改变可绘制的背景,只能改变颜色。
你可以试试
public void setBackground (Drawable background)
-Set the background to a given Drawable, or remove the background
您的问题不在于 CardView
本身,而在于您的主持人。将此行放入您的 RowPresenter
/ListRowPresenter
:
listRowPresenter.setShadowEnabled(false);
此外,在 this Medium article 中你可以看到如何让你 CardView
循环。它显示了如何在行未聚焦时删除阴影,覆盖 isUsingDefaultListSelectEffect()
方法始终为 false
.
我开始使用新的 android.support.v17.leanback
库,但在样式 ImageCardView
方面遇到了一些问题。
我正在将 ImageCardView
上的图像更改为不同的形状,因此我想删除在 ListRow
中使用卡片时自动生成的背景和阴影。如果我离开阴影,我的名片看起来很奇怪,因为显示的阴影和背景就像名片是正方形的。
我试过为所有元素设置不同的背景,但它不起作用。如果我设置正常背景颜色(绿色、蓝色等),图像或信息区域的背景会发生变化,但如果我设置透明背景,则可以看到另一个包裹整个卡片的背景。
有解决这个问题的想法吗?
根据这个
你可以试试
public void setBackground (Drawable background)
-Set the background to a given Drawable, or remove the background
您的问题不在于 CardView
本身,而在于您的主持人。将此行放入您的 RowPresenter
/ListRowPresenter
:
listRowPresenter.setShadowEnabled(false);
此外,在 this Medium article 中你可以看到如何让你 CardView
循环。它显示了如何在行未聚焦时删除阴影,覆盖 isUsingDefaultListSelectEffect()
方法始终为 false
.