Merge pull request #8633 from Isira-Seneviratne/Use_ViewCompat_setBackgroundTintList
Use ViewCompat.setBackgroundTintList().
This commit is contained in:
commit
cd14096dbe
1 changed files with 4 additions and 3 deletions
|
@ -12,6 +12,7 @@ import android.view.View
|
||||||
import androidx.annotation.ColorInt
|
import androidx.annotation.ColorInt
|
||||||
import androidx.annotation.FloatRange
|
import androidx.annotation.FloatRange
|
||||||
import androidx.core.animation.addListener
|
import androidx.core.animation.addListener
|
||||||
|
import androidx.core.view.ViewCompat
|
||||||
import androidx.core.view.isGone
|
import androidx.core.view.isGone
|
||||||
import androidx.core.view.isInvisible
|
import androidx.core.view.isInvisible
|
||||||
import androidx.core.view.isVisible
|
import androidx.core.view.isVisible
|
||||||
|
@ -101,11 +102,11 @@ fun View.animateBackgroundColor(duration: Long, @ColorInt colorStart: Int, @Colo
|
||||||
viewPropertyAnimator.interpolator = FastOutSlowInInterpolator()
|
viewPropertyAnimator.interpolator = FastOutSlowInInterpolator()
|
||||||
viewPropertyAnimator.duration = duration
|
viewPropertyAnimator.duration = duration
|
||||||
viewPropertyAnimator.addUpdateListener { animation: ValueAnimator ->
|
viewPropertyAnimator.addUpdateListener { animation: ValueAnimator ->
|
||||||
backgroundTintList = ColorStateList(empty, intArrayOf(animation.animatedValue as Int))
|
ViewCompat.setBackgroundTintList(this, ColorStateList(empty, intArrayOf(animation.animatedValue as Int)))
|
||||||
}
|
}
|
||||||
viewPropertyAnimator.addListener(
|
viewPropertyAnimator.addListener(
|
||||||
onCancel = { backgroundTintList = ColorStateList(empty, intArrayOf(colorEnd)) },
|
onCancel = { ViewCompat.setBackgroundTintList(this, ColorStateList(empty, intArrayOf(colorEnd))) },
|
||||||
onEnd = { backgroundTintList = ColorStateList(empty, intArrayOf(colorEnd)) }
|
onEnd = { ViewCompat.setBackgroundTintList(this, ColorStateList(empty, intArrayOf(colorEnd))) }
|
||||||
)
|
)
|
||||||
viewPropertyAnimator.start()
|
viewPropertyAnimator.start()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue