There is a normal scaling animation.

<scale android:fromXScale="1.0" android:fromYScale="1.0" android:pivotX="50%" android:pivotY="50%" android:toXScale="1.3" android:toYScale="1.3" android:duration="1000" /> 

I need to, at the end of the animation, the image remains in the state of Scale = 1.3, and does not go into the initial phase of Scale = 1.0.

I tried to programmatically establish that at the end of the animation the desired image becomes Scale = 1.3, but it does not work correctly, the picture is twitching.

 scale.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationEnd(Animation animation) { start1_value=1; Start1.setScaleX((float) 1.3); Start1.setScaleY((float) 1.3); } }); 

Tell me, how can I solve this problem?

  • What are you animating? - VAndrJ

1 answer 1

Use ObjectAnimator:

 ObjectAnimator scaleX = ObjectAnimator.ofFloat(view, "scaleX", 1.3f); ObjectAnimator scaleY = ObjectAnimator.ofFloat(view, "scaleY", 1.3f); AnimatorSet scale = new AnimatorSet(); scaleX.setDuration(1000); scaleY.setDuration(1000); scale.play(scaleX).with(scaleY); scale.start(); 

Or for ImageView:

 imageView.animate().scaleX(toX).scaleY(toY).setDuration(1000);