Monday, April 29, 2013

Android-Animate Images Cyclically

To Animate Images cyclically for an image view create an animation drawable


    AnimationDrawable animation = new AnimationDrawable();
    animation.addFrame(getResources().getDrawable(R.drawable.image1), 100);
    animation.addFrame(getResources().getDrawable(R.drawable.image2), 100);
    animation.addFrame(getResources().getDrawable(R.drawable.image3), 100);
    animation.setOneShot(false);

    ImageView imageAnim =  (ImageView) findViewById(R.id.img);
    imageAnim.setBackgroundDrawable(animation);

    // start the animation!
    animation.start()

No comments:

Post a Comment