ObjectAnimator with scale property makes bg black?

后端 未结 3 1124
青春惊慌失措
青春惊慌失措 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:14

    It may not be the cleanest solution, but adding animation update listener and invalidating the parent might do the job.

    ObjectAnimator scaleDownX = ObjectAnimator.ofFloat(view, "scaleX", 0.5f);
    ObjectAnimator scaleDownY = ObjectAnimator.ofFloat(view, "scaleY", 0.5f);
    scaleDownX.setDuration(1000);
    scaleDownY.setDuration(1000);
    
    AnimatorSet scaleDown = new AnimatorSet();
    scaleDown.play(scaleDownX).with(scaleDownY);
    
    scaleDownX.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
         @Override
         public void onAnimationUpdate(ValueAnimator valueAnimator) {
             View p= (View) v.getParent();
             p.invalidate();
         });
    scaleDown.start();
    

提交回复
热议问题