I have a problem with scaleX and scaleY animations using ObjectAnimator.
At the end of animation, the Drawable inside is resized but not the size of the border of the ImageView.
Schema of my problem : click here
XML ImageView code
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/avenger"
android:background="@null"
android:id="@+id/vaisseau"
android:adjustViewBounds="true"
android:layout_above="@+id/santeBouclier"
android:layout_centerHorizontal="true" />
Animation code:
ImageView avenger = (ImageView)this.jeu.findViewById(R.id.vaisseau);
AnimatorSet resizeAvenger = new AnimatorSet();
ObjectAnimator animResizeX = ObjectAnimator.ofFloat(avenger, "scaleX", 1f, 0.3f);
animResizeX.setDuration(4000);
ObjectAnimator animResizeY = ObjectAnimator.ofFloat(avenger, "scaleY", 1f, 0.3f);
animResizeY.setDuration(4000);
resizeAvenger.playTogether(animResizeX, animResizeY);
resizeAvenger.start();
I think my problem is here :
Before the animation :
avenger.getScaleX() = 1
avenger.getWidth() = 190
After the animation :
avenger.getScaleX() = 0.3
avenger.getWidth() = 190
multiply width and scale factor as said here: