ObjectAnimator with scale property makes bg black?

后端 未结 3 1104
青春惊慌失措
青春惊慌失措 2021-01-04 17:16

I use ObjectAnimator to scale down a RelativeLayout :

            ObjectAnimator scaleDownX = ObjectAnimator.ofFloat(view, \"scaleX\", 0.5f);
            Obj         


        
3条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-04 18:10

    The reason why the previous answer is needing to invalidate the parent is because your AnimatorSet scaleDown has no Target. You should set the Target of your ObjectAnimator's to null and set the Target on the AnimatorSet. Or a better way would be to use the code below:

    ObjectAnimator scaleDown = ObjectAnimator.ofPropertyValuesHolder(view, 
        PropertyValuesHolder.ofFloat("scaleX", 0.5f),
        PropertyValuesHolder.ofFloat("scaleY", 0.5f));
    scaleDown.setDuration(1000);
    scaleDown.start();
    

提交回复
热议问题