Android objectAnimator animate backgroundColor of Layout

前端 未结 2 1985
感动是毒
感动是毒 2020-12-05 15:20

I have a problem. I want to animate the background color of a LinearLayout, using ObjectAnimator.
The problem is that it anima

2条回答
  •  春和景丽
    2020-12-05 16:02

    It seems to be an old issue. I stumbled on this question while having a similar problem.

    At the end it was just a bug in Android. The code is supposed to work, but the AnimatorInflater just blunders when setting the evaluator.

    So setting the TypeEvaluator after the inflation again would do the trick.

        ObjectAnimator objAnim = (ObjectAnimator)AnimatorInflater.loadAnimator(getActivity(), R.animator.animator_bkg);
        objAnim.setTarget(view);
        objAnim.setEvaluator(new ArgbEvaluator());
        objAnim.start();
    

    Set to new ArgbEvaluator() the animation works like intended.

提交回复
热议问题