today I'm trying to make blink effect in my CardView... Works if I put backgroundColor but does not if I use strokeColor. I've followed this tutorial to make it real but is not working really... How can I change to make this effect correctly?
private fun createBlinkEffect() {
val animator = ObjectAnimator.ofInt(mCardView,
"strokeColor",
ContextCompat.getColor(this, COLOR.WHITE),
ContextCompat.getColor(this, COLOR.RED))
animator.duration = 400
animator.setEvaluator(ArgbEvaluator())
animator.repeatMode = ValueAnimator.REVERSE
animator.repeatCount = ValueAnimator.INFINITE
animator.start()
}
this is my layout_item
<androidx.cardview.widget.CardView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/mCardView"
android:layout_width="120dp"
android:layout_height="152dp"
android:layout_marginEnd="24dp"
android:layout_marginBottom="4dp"
app:strokeWidth="2dp"
app:strokeColor="@android:color/transparent"
app:cardCornerRadius="12dp">
Thanks for your time
That's it!
Ps. Remember use
MaterialCardViewinsteadCardViewand set a defaultstrokeWidthandstrokeColor