the CardView ( android.support.v7.cardview ) stays white even though I set a backround drawable via android:backround - The documentation gives me the feeling that it should work. No Idea what I am doing wrong here.
问题:
回答1:
I know this is an old question, but I have a simple solution - just make the first child of your CardView an ImageView and specify the scale type to fitXY. You can get rid of the extra CardView padding by setting cardElevation and cardMaxElevation to 0dp
:
<... your="" layout="" ...="">
回答2:
Make Cardview will host one viewgroup for eg relative layout in this case and then simply set any background to relative layout.
回答3:
for drawable or color just use:
cvSellerShopp.setBackgroundResource(R.drawable.ic_action_add_image);
for color use:
cvSellerShopp.setCardBackgroundColor(R.color.colorPrimary);
but this one does not produce the intended results
回答4:
Try this
card_view:cardBackgroundColor="@android:color/holo_green_dark
here you can set any color or make it transparent by giving color transparent and if u wand some drawable like image or svg put RelativeLayout background
回答5:
You can use LinearLayout or Relative layout inside CardView and set drawable background it like below :
Below is my Drawable resource file :
回答6:
Use cardview:cardBackgroundColor
attribute:
android.support.v7.cardview:cardBackgroundColor="@color/black"
or in code,
myCardViewObject.setCardBackgroundColor(someIntColor)
more info here: https://developer.android.com/reference/android/support/v7/widget/CardView.html