开发者

Android java stop a animation after completed

开发者 https://www.devze.com 2023-04-08 16:31 出处:网络
How can i stop a animation after it has completed? My animation is the image fades in code: Java: super.on开发者_C百科Create(savedInstanceState);

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

精彩评论

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