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

后端 未结 6 2016
我寻月下人不归
我寻月下人不归 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条回答
  •  -上瘾入骨i
    2020-12-23 10:22

    Better answer to this question would be to use ObjectAnimator

    ObjectAnimator colorFade = ObjectAnimator.ofObject(view, "backgroundColor" /*view attribute name*/, new ArgbEvaluator(), mContext.getResources().getColor(R.color.colorMenuOverlay) /*from color*/, Color.WHITE /*to color*/);
                    colorFade.setDuration(3500);
                    colorFade.setStartDelay(200);
                    colorFade.start();
    

提交回复
热议问题