我试图将无限动画添加到我的应用程序中,但是它不起作用。这是动画(它放大和缩小 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>
我添加了这样的代码:
binding.txtHelp.setOnClickListener {
val animation = AnimationUtils.loadAnimation(App.context, R.anim.zoomin)
animation.repeatCount = Animation.INFINITE
it.startAnimation(animation)
}
或者我尝试在刻度上设置
android:repeatCount="infinite"
,但问题是第一个刻度始终执行,而不是在第二个刻度之后执行。
最佳答案
好的,我结合了所有答案,最终做到了:
<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" />
这很好。
android:repeatCount="infinite"
只是一个比例,android:repeatMode="reverse"
也只有一个比例,因此 View 可以平滑地放大和缩小
关于android - Android中的无限动画不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62322737/