In Android, how do I smoothly fade the background from one color to another? (How to use threads)

后端 未结 6 1997
我寻月下人不归
我寻月下人不归 2020-12-23 09:59

I\'ve been playing with Android programming on and off for a couple of weeks, and I\'m trying to get something to work that seems simple, but I think I am missing something.

6条回答
  •  醉梦人生
    2020-12-23 10:43

    private fun applyColorFade(fromColor: Int, toColor: Int) {
        ObjectAnimator.ofObject(
            toolbar, "backgroundColor", ArgbEvaluator(), 
            fromColor,
            toColor
        ).apply {
          duration = 2000
          startDelay = 200
          start()
        }
    }
    

    // this is a reusable method for color fade animation for a view

提交回复
热议问题