What is the difference between these two animation approaches? They both achieve the same result, but the first one is jerky while the second one is smooth. Why?
This animation progresses nicely until the very end when it suddenly jumps into its final position. Everything seems to be very straightforward, so whats up with this?
val cube = homeBinding.imgCube
val animSet = AnimationSet(true)
val rotateAnimation = RotateAnimation(0.0f,
720.0f,
Animation.RELATIVE_TO_SELF,
0.5f,
Animation.RELATIVE_TO_SELF,
0.5f)
val scaleAnimation: Animation = ScaleAnimation(
0.1f, 0.4f,
0.2f, 0.4f,
Animation.RELATIVE_TO_SELF, 0.5f,
Animation.RELATIVE_TO_SELF, 0.5f)
scaleAnimation.interpolator = LinearInterpolator()
rotateAnimation.interpolator = LinearInterpolator()
animSet.duration = 3000
animSet.addAnimation(rotateAnimation)
animSet.addAnimation(scaleAnimation)
cube.startAnimation(animSet)
and xml:
<ImageView
android:id="@+id/imgCube"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:contentDescription="some"
android:scaleType="centerInside"
android:scaleX="0.4"
android:scaleY="0.4"
app:srcCompat="@drawable/kk" />
While this one works just fine.
But what's the difference?
cube.animate().scaleX(0.4f)
.scaleY(0.4f)
.setDuration(3000)
.rotation(720f)
.setInterpolator (LinearInterpolator())
.start();

