gpt4 book ai didi

android - 为什么我的动画不重复?

转载 作者:塔克拉玛干 更新时间:2023-11-02 22:05:30 26 4
gpt4 key购买 nike

我已将 repeatCount 设置为 INFINITE (-1) 并将 repeatMode 设置为 RESTART (1)

http://developer.android.com/reference/android/view/animation/Animation.html#INFINITE

即使我的动画有效,也无法正确重复。我的代码中缺少什么?

public class SyncActivity extends Activity {

Animation slideanim;
ImageView senoide;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_sync);

senoide = (ImageView) findViewById(R.id.imageView3);

slideanim = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.move);
//slideanim.setFillAfter(true);
slideanim.setRepeatCount(Animation.INFINITE);
slideanim.setRepeatMode(Animation.RESTART);

senoide.setAnimation(slideanim);
senoide.startAnimation(slideanim);
}
}

移动.xml

<set xmlns:android="http://schemas.android.com/apk/res/android"
android:shareInterpolator="false">
<translate android:fromXDelta="0%" android:toXDelta="-18.5%"
android:fromYDelta="0%" android:toYDelta="0%"
android:duration="1000"/>
</set>

最佳答案

更改您的 XML 以具有重复模式并依靠它:

<set xmlns:android="http://schemas.android.com/apk/res/android"
android:shareInterpolator="false">
<translate android:fromXDelta="0%" android:toXDelta="-18.5%"
android:fromYDelta="0%" android:toYDelta="0%"
android:repeatCount="infinite"
android:repeatMode="restart"
android:duration="1000"/>
</set>

关于android - 为什么我的动画不重复?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27508874/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com