How display a loading image correctly on Android phone - android

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?

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.

Related

Display a gif image in Custom listview android?

I want to display a gif image http://peacechild.org/wp-content/uploads/2012/09/loading.gif
in each element of custom listview.
How to do that?
I know that we have to make use of the movie class but how to use it?
An example would be helpfull.
Thanks
Use this Animated GIF app sample
OR
Use a webview to load it
Use VideoView.
Natively ImageView does not support animated image. You have two options to show animated gif file
1.Use VideoView
2.Use ImageView and Split the gif file into several parts and then apply animation to it

download images using URL and then show them using custom PagerAdapter

I'd like to download a bunch of images from web and then show them using my custom PagerAdapter. So I can slide to browse all of these images. Please see the following figure:
HttpURLConnection is used to download the image in background and BitmapFactory is used to produce the bitmap.
There is one problem for this app. It's not fluid when sliding to the next image. There is an obvious pause when showing the next image. How to solve this problem. Any suggestions?
If you dont load the image in the background, it will block the Main thread, so your app is not so fluid.
you can try the following open source project:
https://github.com/nostra13/Android-Universal-Image-Loader
https://github.com/lianghanzhen/ImageCacheAndLoader

Android Loading Indicator for Downloading Images

I am using an Image Loaded which loads images based on requirment and since the images are big. I want to display an intermediate Spinning Image showing which would convey that the image is loading to the User.
I am displaying these images in the Viewpager.
We can not use a Gif image to display the animation and i wonder how it can be done.
P.S i am not looking for a Progress Dialog.
You could try doing a View Animation on the ImageView. Rotate is one of the included animations, and you can define it in XML.
Here's a Youtube Video from Google explaining it a little more.

webview setBackgroundColor when play gif image

i want to play gif use web view,default webview background is white.so i use :
webView.setBackgroundColor(Color.TRANSPARENT);
but when i use the above code,my gif can play,but behind of my gif it also draw one pic of gif
as:
In the pic you will see a redundant pic at the behind. My original gif pic is like this:
When I was trying to delete webView.setBackgroundColor(Color.TRANSPARENT), the gif was showing good, but background was white.
When i add the code, my gif always have a a redundant pic of the gif.
So my question is: how can I set my gif background as transparent but not mess up the gif?

Android smooth image animation

I am working on image animation. I have 200 transparent png images which I am trying to show one by one over a background image.
Can you tell me the best way to do it. The image should change in such a way that it should appear that a cartoon is running.
If you can tell me in steps, it will be great.
Have a look at animation frames: http://developer.android.com/guide/topics/resources/animation-resource.html#Frame
You can use animation-list to play them frame by frame
http://app-solut.com/blog/2011/05/playing-animations-in-android/
or create a GIF and play it
http://droid-blog.net/2011/10/14/tutorial-how-to-use-animated-gifs-in-android-part-1/
Gif is more lightweigt, but it gave me trouble once when played on some MDPI screen devices, where I had a single Gif file in the drawable-hdpi folder. So give it a try first..

Categories

Resources