How to start a second animation list after the end of the first animation list

I want to start the second animation list after the end of the first animation list. First animation list (list_first):

<?xml version="1.0" encoding="utf-8"?> 

 <item android:drawable="@drawable/f11" android:duration="500"/> <item android:drawable="@drawable/delay" android:duration="1000"/> <item android:drawable="@drawable/f12" android:duration="500"/> <item android:drawable="@drawable/delay" android:duration="1000"/> </animation-list> 

Second animation list (list_second):

 <?xml version="1.0" encoding="utf-8"?> 

 <item android:drawable="@drawable/s21" android:duration="500"/> <item android:drawable="@drawable/delay" android:duration="1000"/> <item android:drawable="@drawable/s22" android:duration="500"/> <item android:drawable="@drawable/delay" android:duration="1000"/> </animation-list> 

now how to start the second animation list at the end of the first list?

 ImageView img1; TextView t1; AnimationDrawable splashanimation; @Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.anim_layout); img1= (ImageView)findViewById(R.id.anim_imgview); img1.setBackgroundResource(R.drawable.list_first); splashanimation = (AnimationDrawable)img1.getBackground(); splashanimation.start(); 

Now I do not understand what to do? how to run the second animation list at the end of the first list. suggest

0
source share
1 answer

Try the following:

 splashanimation = (AnimationDrawable)img1.getBackground(); splashanimation.start(); Handler handler = new Handler(); handler.postDelayed(new Runnable() { public void run() { //start your 2nd animation //secondAnimation.start(); } }, delay);//delay = the duration of your first animation, i think its 3000 in your case 

Or you can combine 2 xml animation in one:

combine_anim.xml file

 <?xml version="1.0" encoding="utf-8"?> <animation-list> <item android:drawable="@drawable/f11" android:duration="500"/> <item android:drawable="@drawable/delay" android:duration="1000"/> <item android:drawable="@drawable/f12" android:duration="500"/> <item android:drawable="@drawable/delay" android:duration="1000"/> <item android:drawable="@drawable/s21" android:duration="500"/> <item android:drawable="@drawable/delay" android:duration="1000"/> <item android:drawable="@drawable/s22" android:duration="500"/> <item android:drawable="@drawable/delay" android:duration="1000"/> </animation-list> 

And you use combine_anim.xml as the background instead of list_first.xml

+2
source

All Articles