Onwuka Daniel
Onwuka Daniel

Reputation: 164

CardView background color doesn't change even after using app:cardBackgroundColor property

I am making effort to change my cardView background color to a different color other than the default color set in style with the colorSurface property. I am aware colorSuface is responsible for a cardView color, but it is surprisingly difficult to change it color in XML. I have tried the following singly and together but there is no effect.

android:background="@color/purple_200"
app:cardBackgroundColor="@color/purple_200"
android:backgroundTint="@color/purple_200"

I will appreciate help.

Here is my styles code <item name="colorSurface">@color/app10</item>

The reason I don't want to change the colorSurface property is because, that is the default desired color I want for all cardView but in this particular layout, I want to style my row of cardView widgets with tones of a color, unfortunately, it is not responding.

Upvotes: 3

Views: 2096

Answers (1)

Onwuka Daniel
Onwuka Daniel

Reputation: 164

I figured out the issue was the color set to an imageView inside the cardView was overlaying the color of the cardView. Another possible cause of this kind of behaviour is if the cardView was inside a layout whose elevation (layout) is possibly greater than the cardView.

Thanks @Mike M for asserting that cardView doesn't disappoint in this case.

Upvotes: 1

Related Questions