如何在android中更改卡片视图的颜色

时间:2017-05-22 09:28:11

标签: android android-cardview

我想在用户点击时更改cardview的背景颜色。任何人都可以建议我这样做吗?

1 个答案:

答案 0 :(得分:0)

在onClick()方法中使用setCardBackgroundColor():

    cardView1.setCardBackgroundColor(R.color.colorPrimary);