How can i stop the animation

how can i stop the animation .. this is my code

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.Button;
import android.widget.ImageView;

public class animation extends Activity {

    ImageView img;
    Animation an;
    Button bt;

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        img = (ImageView)findViewById(R.id.ImageView01);
        an = AnimationUtils.loadAnimation(this, R.anim.anim);
        bt= (Button)findViewById(R.id.Button01);

        bt.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub
                img.startAnimation(an);
            }
        });
    }
}
+3
source share
2 answers

I assume your animation is endless. If you want this to stop using img.clearAnimation();.

+7
source

You should start looking in the API for its first method mentioned:

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

0
source

Source: https://habr.com/ru/post/1792512/


All Articles