如何设置cardview drawable背景?

时间:2016-09-20 19:26:34

标签: android

如何解决这个问题?

holder.cardView.setBackgroundResource(R.drawable.in_message_bg);

1 个答案:

答案 0 :(得分:1)

试试这个

card.setCardBackgroundColor(R.drawable.circle)

或者您可以尝试通过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">

希望这有效。

相关问题