开发者

Android java stop a animation after completed

How can i stop a animation after it has completed?

My animation is the image fades in

code:

Java:

        super.on开发者_C百科Create(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>


Try removing the android:repeatCount="infinite", since you do not want it to repeat.


If it is a non repeating animation it will end when it is done otherwise you can just set the repeat counter to 0 to let it end after the current execution.

fadeInAnimation.setRepeatCount( 0 );
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜