1

I have two images (PNGs). One is how "animation" should look at start and second is how "animation" should look at the end of "animation" Now is there any helper class/method in which I'd say this is my start image (image1), this is my end image (image2) and it should last 10 seconds and that method will create animation between these two images? And if possible set it to endless repeat mode?

10x

Regards

zmeda
  • 2,909
  • 9
  • 36
  • 56

2 Answers2

1

Yeah you want to do a frame-by-frame animation. Here's a simple guide on how to do it; http://developer.android.com/guide/topics/graphics/drawable-animation.html

You can also do things like make it loop, and set the time between each image.

<animation-list xmlns:android="http://schemas.android.com/apk/res/android"
    android:oneshot="false">
    <item android:drawable="@drawable/my_image1" android:duration="10000" />
    <item android:drawable="@drawable/my_image2" android:duration="10000" />
</animation-list>

Use that in your resource file, and then just copy the code in that example.

You could also use a TransitionDrawable but I don't know how you would achieve the looping http://developer.android.com/reference/android/graphics/drawable/TransitionDrawable.html

Here's another question about fading from one image to another, but once again, these are one shot transitions. How to do a fadein of an image on an Android Activity screen? the answer at the bottom might actually be helpful to you.

Community
  • 1
  • 1
evanmcdonnal
  • 46,131
  • 16
  • 104
  • 115
  • AFAIK this will show my_image1 for 10 secs and than my_image2 for another 10 secs and that's it. I want to "translate" from my_image1 to my_image2 for 10 secs. In other words I want to start animation with my_image1 and than do all the approximation needed to show final image my_image2. – zmeda Feb 17 '12 at 07:53
  • There are some other approaches you could use but none of them will do everything you want. You'll have to come up with some kind of a solution by combing them. I'll edit my post with a couple of suggestions. – evanmcdonnal Feb 17 '12 at 08:04
0

Android don't have such methods. you can try FrameAnimation, but you should provide all the frames. Maybe a tools to create animation frames will help you, which is used in game develpment or another.

JohnCookie
  • 661
  • 3
  • 7
  • This is wrong. You can easily achieve the desired results with an AnimationDrawable. You specify the two images, set oneshot to false and set the the time to 10,000. – evanmcdonnal Feb 17 '12 at 07:45
  • Thx, I consider that he only has the start and end Animation,don't have the frames in middle, use FrameAnimation will only show startImage for 10s and then show endImage, but not a smooth animation like .gif – JohnCookie Feb 17 '12 at 07:49