Android java完成后停止动画

时间:2011-09-27 22:48:22

标签: java android

如何在动画完成后停止动画?

我的动画是图像淡出

代码:

Java:

        super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    ImageView imageView= (ImageView)findViewById(R.id.tCat);
    Animation fadeInAnimation = AnimationUtils.loadAnimation(this, R.anim.anim);
    imageView.startAnimation(fadeInAnimation );

XML

    <?xml version="1.0" encoding="utf-8"?>
  <set xmlns:android="http://schemas.android.com/apk/res/android">
    <alpha android:fromAlpha="0.0" android:toAlpha="1.0" 
     android:interpolator="@android:anim/accelerate_interpolator" 
   android:duration="5000"
    android:repeatCount="infinite"/>
    </set>

2 个答案:

答案 0 :(得分:3)

尝试删除android:repeatCount =“infinite”,因为你不想重复它。

答案 1 :(得分:1)

如果是非重复动画,它将在完成后结束,否则你可以将重复计数器设置为0,让它在当前执行后结束。

fadeInAnimation.setRepeatCount( 0 );
相关问题