9

Problem: Shows only the first element in the animation-list.

Animation list drawable file in res/drawable:

<?xml version="1.0" encoding="utf-8"?>
<animation-list xmlns:android="http://schemas.android.com/apk/res/android"
android:oneshot="false" >

  <item
    android:drawable="@drawable/k2si"
    android:duration="1000"/>
  <item
    android:drawable="@drawable/android"
    android:duration="1000"/>

</animation-list>

Starting the animation:

    ImageView image = (ImageView) findViewById(R.id.imageView1);
    image.setBackgroundResource(R.drawable.screensaver_image);
    ((AnimationDrawable) image.getBackground()).start();

Documentation (scroll to Frame animation)

Indrek Kõue
  • 6,449
  • 8
  • 37
  • 69

2 Answers2

7

Please see the similar question here

Starting frame by frame animation

you will get an idea about frame by frame animation.

If you didn't understood check the link below, good tutorial for frame by frame animation using XML file.

frame by frame xml animation with google android

Community
  • 1
  • 1
Yugandhar Babu
  • 10,311
  • 9
  • 42
  • 67
-2

You can achieve same thing from layout xml itself,

just mentioned android:src="@drawable/rode_anim" which is nothing but your custom animation-list drawable.

CoDe
  • 11,056
  • 14
  • 90
  • 197