开发者

How display a loading image correctly on Android phone

开发者 https://www.devze.com 2023-01-31 17:53 出处:网络
I have been trying to use a .gif file from my resources, but I get no movement when it loads.I am using i开发者_Python百科t as a loading image while I am doing an asynchronous task.I was previously us

I have been trying to use a .gif file from my resources, but I get no movement when it loads. I am using i开发者_Python百科t 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?


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


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消