frame-by-frame animation detection

Quickly share your Android Code Snippets here...

frame-by-frame animation detection

Postby ExcoDev » Tue Aug 10, 2010 8:18 am

Hi Friends,

I have done frame-by-frame animation using xml. My codes are below. Now what I want is once an animation is completed then next animation has to start. After completion of one the next animation should begin.

xml file

<?xml version="1.0" encoding="utf-8"?>
<animation-list xmlns:android="http://schemas.android.com/apk/res/android"
android:oneshot="true">
<item android:drawable="@drawable/f6" android:duration="100" />
<item android:drawable="@drawable/f7" android:duration="100" />
<item android:drawable="@drawable/f8" android:duration="100" />
<item android:drawable="@drawable/f9" android:duration="100" />
<item android:drawable="@drawable/f10" android:duration="100" />
<item android:drawable="@drawable/f11" android:duration="100" />
</animation-list>

code in program

imgView = (ImageView)findViewById(R.id.animationImage);
imgView.setVisibility(ImageView.VISIBLE); imgView.setBackgroundResource(R.drawable.frame_animation1);
frameAnimation =(AnimationDrawable) imgView.getBackground();
imgView.post(new Starter());

Now, after finishing this animation I want to start another animation by using the below code
imgView.setBackgroundResource(R.drawable.frame_animation32);

Please, let me know how will I do it.

Thanks
ExcoDev
Once Poster
Once Poster
 
Posts: 1
Joined: Tue Aug 10, 2010 7:34 am

Top

Re: frame-by-frame animation detection

Postby guruk » Sat Aug 21, 2010 4:17 pm

Did you found any solution till now? I am also interested :)
guruk
Junior Developer
Junior Developer
 
Posts: 24
Joined: Sun Mar 08, 2009 8:05 pm

Re: frame-by-frame animation detection

Postby darolla » Mon Sep 20, 2010 10:35 pm

every animation object has a listener interface with a onstartanimation and onstopanimation.

there you can chain your animations :)
User avatar
darolla
Master Developer
Master Developer
 
Posts: 273
Joined: Thu Sep 25, 2008 5:16 pm
Location: Dortmund, Germany

Re: frame-by-frame animation detection

Postby rattlebrain » Fri Sep 24, 2010 7:15 pm

The frame-by-frame style of animation doesn't use animation objects, so there's no listener w/ onstopanimation to use. There is a public method isRunning() described here: http://developer.android.com/reference/ ... ning%28%29

So, we should be able to figure out if the first part of our animation has stopped so we know it's time to start the next section. But I haven't figured out a good way to loop or wait until isRunning returns false. Any suggestions?
rattlebrain
Once Poster
Once Poster
 
Posts: 1
Joined: Tue Sep 21, 2010 2:53 pm

Top

Return to Code Snippets for Android

Who is online

Users browsing this forum: Google Feedfetcher and 3 guests