I have an animation with 500 frame. I should create bitmap for each of them to show in live wallpaper's canvas, but it get a lot of performance, How can I do it ?
Asked
Active
Viewed 235 times
1 Answers
0
You can use animation-list. For example:
<?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/frame1" android:duration="100" />
<item android:drawable="@drawable/frame2" android:duration="100" />
<item android:drawable="@drawable/frame3" android:duration="100" />
<item android:drawable="@drawable/frame4" android:duration="100" />
<item android:drawable="@drawable/frame5" android:duration="100" />
......
</animation-list>
You can associate this resource to a background view and when you want start the animation.
Hope it helps you!

Alejandro Martínez Martínez
- 2,038
- 1
- 18
- 29
-
Will it be seedy enough to be set as background wallpaper and run for 24 hours??? – Nadeem Iqbal Oct 06 '14 at 10:23
-
1I think that it is a good way to do this. When you init the animation you should use something like this: ivGif.post(new Runnable() { @Override public void run() { AnimationDrawable frameAnimation = (AnimationDrawable) ivGif.getBackground(); frameAnimation.start(); frameAnimation.setOneShot(true); } }); – Alejandro Martínez Martínez Oct 06 '14 at 10:27
-
How can I use animation list in live wallpaper in canvas ? I want run it for 24 houres. thanks alot – Project Stackoverflow Oct 06 '14 at 10:49
-
really need to use canvas??? If you need to use canvas, i remember that in canvas you can paint a drawable resource. (animation-list is a drawable resource). – Alejandro Martínez Martínez Oct 06 '14 at 10:52