我尝试将无限动画添加到我的应用中,但是它不起作用。我将android:repeatCount="infinite"
这样添加到XML文件中:
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:repeatCount="infinite">
<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" />
<set android:startOffset="1000">
<scale
android:duration="1000"
android:fromXScale="1"
android:fromYScale="1"
android:pivotX="50%"
android:pivotY="50%"
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)
}
以两种方式执行动画一次