I have a CardView which is getting colored after a button click ("reveal right answer" functionality). The card needs to get back to it's original color for the next question. I am using the default Android color, but I couldn't find the value I need to reset to (R.attr.cardBackgroundColor turns my card blue...), so I used tint like so:
@BindingAdapter("isRight", "showResult")
fun CardView.setCardTint(
isRight: Boolean,
showResult: Boolean,
) {
background.setTintList(null)
if (showResult) {
val colorRes = if (isRight) R.color.result_right
else R.color.result_wrong
background.setTint(ContextCompat.getColor(context, colorRes))
}
}
This works great, but now I need to change the colors to gradients. For that I need to go back to the original solution and change the background itself (to the gradient drawables) - and to my original problem: How to reset the CardView background to it's Android default value?