CardView有一个属性card_view:cardBackgroundColor
来定义背景颜色。此属性工作正常。
同时没有动态改变颜色的方法。
我刚刚尝试了以下解决方案:
mCardView.setBackgroundColor(...);
或在 cardView 内使用 Layout
<android.support.v7.widget.CardView>
<LinearLayout
android:id="@+id/inside_layout">
</android.support.v7.widget.CardView>
View insideLayout = mCardView.findViewById(R.id.inside_layout);
cardLayout.setBackgroundColor(XXXX);
这些解决方案不起作用,因为该卡有一个 cardCornerRadius。