问题
I started using new android.support.v17.leanback
library and have some trouble in styling ImageCardView
.
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?
回答1:
Your problem is not about the CardView
itself, it's about your presenter. Put this line your RowPresenter
/ListRowPresenter
:
listRowPresenter.setShadowEnabled(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
.
回答2:
According to this post, you cannot change the background drawable, only the color.
You can try
public void setBackground (Drawable background)
-Set the background to a given Drawable, or remove the background
来源:https://stackoverflow.com/questions/36624317/remove-background-from-imagecardview