Remove background from ImageCardView

折月煮酒 提交于 2019-12-02 09:57:07

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!