Reputation: 9872
I tried to add infinite animation to my app but it doesn't work. This is animation (it zoom in and zoom out view):
<set xmlns:android="http://schemas.android.com/apk/res/android">
<scale
android:duration="1000"
android:fromXScale="1.0"
android:fromYScale="1"
android:pivotX="50%"
android:pivotY="50%"
android:toXScale="0.5"
android:toYScale="0.5" />
<scale
android:duration="1000"
android:fromXScale="1"
android:fromYScale="1"
android:pivotX="50%"
android:pivotY="50%"
android:startOffset="1000"
android:toXScale="2"
android:toYScale="2" />
</set>
I added a code like this:
binding.txtHelp.setOnClickListener {
val animation = AnimationUtils.loadAnimation(App.context, R.anim.zoomin)
animation.repeatCount = Animation.INFINITE
it.startAnimation(animation)
}
Or I tried to set android:repeatCount="infinite"
on scales but the problem is that the first scale is executing the whole time, not after the second scale.
Upvotes: 1
Views: 418
Reputation: 9872
Okay, I combined all answers and I ended up on doing this:
<scale
android:repeatCount="infinite"
android:repeatMode="reverse"
android:duration="1000"
android:fromXScale="1"
android:fromYScale="1"
android:pivotX="50%"
android:pivotY="50%"
android:toXScale="0.5"
android:toYScale="0.5" />
This works fine. Just one scale with android:repeatCount="infinite"
but also android:repeatMode="reverse"
so the view zooms in and out smoothly
Upvotes: 1