When using anim, I could do something like this
ScaleAnimation animation = new ScaleAnimation(0, 1.0, 0, 1.0, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
to scale from 0 to original size of the object.
How could I do the same with ObjectAnimator
or ValueAnimator
?
You could use something like this for ValueAnimator:
ValueAnimator translate = ValueAnimator.ofFloat(1f, 1.5f);
translate.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
float scale = Float.parseFloat(animation.getAnimatedValue().toString());
yourView.setScaleX(scale);
yourView.setScaleY(scale);
}
});
translate.start();
And something like this for ObjectAnimator:
AnimatorSet animationSet = new AnimatorSet();
ObjectAnimator scaleY = ObjectAnimator.ofFloat(view, "scaleY", 1f, 1.5f);
ObjectAnimator scaleX = ObjectAnimator.ofFloat(view, "scaleX", 1f, 1.5f);
animationSet.playTogether(scaleX, scaleY);
animationSet.start();
NOTE: Did not test this code, something might not work properly.