I have been trying to use a .gif file from my resources, but I get no movement when it loads. I am using it as a loading image while I am doing an asynchronous task. I was previously using a progress dialog but now I would like to display the image myself and not use a dialog. How can I get this image to display correctly?
Asked
Active
Viewed 4,017 times
2 Answers
1
Try using AnimationDrawable: http://developer.android.com/reference/android/graphics/drawable/AnimationDrawable.html
Basically, you should split each of the frames in your gif into separate files - such as .png file (say if it had transparency) and specify these files in the <animation-list>
instead. You can also control the duration of each frame.
See the link for code example

f20k
- 3,106
- 3
- 23
- 32
-
do you happen to know if there are any default android loading images that are usable instead? – ninjasense Dec 20 '10 at 22:07
-
Im not sure if android has them, but if you have an image editor, you can copy and rotate the ones off a google search:http://www.google.ca/images?hl=en&q=loading+animation&um=1&ie=UTF-8&source=og&sa=N&tab=wi&biw=1280&bih=918 – f20k Dec 21 '10 at 04:34
0
If you are deadset on using a gif image you can just use a WebView instead of an ImageView. Then make an html doc that displays your gif image. When you show it in the WebView it will be animated for you.

Tim
- 21
- 1
- 4