-3

How to solve this question?

holder.cardView.setBackgroundResource(R.drawable.in_message_bg);
Ravindra Kushwaha
  • 7,846
  • 14
  • 53
  • 103
yakonazaki
  • 11
  • 1
  • 5
  • I dont have the code this line is a exemple code – yakonazaki Sep 20 '16 at 19:28
  • You don't have the code? That's your bug... Have you tried setBackgroundDrawable? – apmartin1991 Sep 20 '16 at 19:41
  • You cannot change background drawable because `CardView` uses background drawable to draw the card. But maybe [this link](https://stackoverflow.com/a/33920684/6017001) will help ... – S.R Aug 25 '17 at 12:09

1 Answers1

1

Try this

card.setCardBackgroundColor(R.drawable.circle)

or You could try via xml

 <android.support.v7.widget.CardView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        card:cardBackgroundColor="#ff00ff"
        card:cardElevation="4dp">

Hope this works.

Meowok
  • 108
  • 1
  • 9