我试图将无限动画添加到我的应用程序中,但是它不起作用。这是动画(它放大和缩小视图):
<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"
使视图平滑地放大和缩小
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句