I have the following code to load an image in Picasso, using a drawable for the placeholder to display while the image is downloading. What I want though is an animated spinning progress bar style spinner that animates around and around while the image is loading, like I see in most professional apps. Picasso doesn't seem to support this, only static image drawables. Is there a way to get it working with Picasso or do I have to do something different?
Picasso.with(context).load(url)
.placeholder(R.drawable.loading)
.error(R.drawable.image_download_error)
.into(view);
How to have a loading progress animation image using Picasso placeholder:
I solved this easily using a animated-rotate xml object.
Steps:
progress_image.png
/res/drawable/progress_animation.xml
Picasso loading:
In this link, Jake Wharton said :
Then you can't
I implemented the progress dialog till the image download and its very simple. Take your ImageView in relative layout and place progress loader on same image view. Apply the below code and handle progress dialog visibility only.
Enjoy. :)
I made it working in following way:
Created a drawable (found somewhere on the Internet) and put it in the res/drawable:
In my item for the GridView added ProgressBar element:
In Adapter added Target Object with following parameters, where poster and spinner are references to ImageView and ProgressBar:
// Target to show/hide ProgressBar on ImageView
Results will be like that on loading - circle is rotating (sorry for this screenshot, but images are appearing too fast): ScreenShot
For anyone trying to use DBragion's technique: Make sure you have the latest version of Picasso or else it wont spin. Mine didn't work until I used version 2.5.2.
Just add shape attribute in DBragion's answer as like below and it will work like charm. Happy coding.
You can use Glide too: