18
プログラムでCardViewの背景色を変更する
CardViewは属性を持ちますcard_view:cardBackgroundColor背景色を定義します。この属性は正常に機能します。 同時に、色を動的に変更する方法はありません。 私は次のような解決策を試しました: mCardView.setBackgroundColor(...); またはcardView内のレイアウトを使用 <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があるため、これらのソリューションは機能しません。