Search code examples
androidloadinggifanimated-gifloading-image

How display a loading image correctly on Android phone


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?


Solution

  • 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