Java 安卓继续循环动画
根据这里的答案,我在动画中尝试了几种循环,例如animation.setRepeatCount(animation.INFINITE);或者anim.xml文件中的android:repeatcount=“infinite”..甚至在java上尝试了while(true)循环,但似乎都不起作用Java 安卓继续循环动画,java,android,xml,loops,animation,Java,Android,Xml,Loops,Animation,根据这里的答案,我在动画中尝试了几种循环,例如animation.setRepeatCount(animation.INFINITE);或者anim.xml文件中的android:repeatcount=“infinite”..甚至在java上尝试了while(true)循环,但似乎都不起作用 <?xml version="1.0" encoding="utf-8"?> <set xmlns:android="http://schemas.android.com/apk/res
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:shareInterpolator="false">
<alpha
android:fromAlpha="0.0"
android:toAlpha="1.0"
android:duration="3000" />
<translate
android:fromXDelta="0.0"
android:toXDelta="0.0"
android:fromYDelta="0.0"
android:toYDelta="100.0"
android:startOffset="3000"
android:duration="3000"
android:repeatCount="infinite"/>
</set>
你能试试这个,看看是否对你有帮助
animation.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
super.onAnimationEnd(animation);
Animation animation = AnimationUtils.loadAnimation(this, R.anim.halloweenanim);
animation.setAnimationListener(this);
img.startAnimation(animation);
}
});
img.startAnimation(animation);
别客气。我找到了解决办法。android:repeatCount=“infinite”应该放在alpha lol中,不需要在java代码中添加.setRepeatCount。XD实际上,AnimationSet有一个错误代码。连医生都说 repeatCount,fillEnabled:这些属性对于 动画集 您可以做的是删除
animation.setRepeatCount(animation.INFINITE)代码>
并为每个动画标记设置android:repeatCount=“infinite”
,而不是父设置标记。我没有得到似乎不起作用的东西?我是指连续循环。它只会设置一次动画,然后什么也不会发生。我想让它保持动画效果。是的,你必须在每个属性中单独添加属性。
animation.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
super.onAnimationEnd(animation);
Animation animation = AnimationUtils.loadAnimation(this, R.anim.halloweenanim);
animation.setAnimationListener(this);
img.startAnimation(animation);
}
});
img.startAnimation(animation);