I'm using Picasso library for image downloading from the network. I just wonder whether I can use a progress dialog or a GIF image as a place holder? Also any idea on how to make place holder image to be smaller (and fit in centre) than the actual image that is downloaded?
I tried going thru the samples but no luck. Any one here who got this to work?
You can use a placeholder image by using the *.placeholder(R.drawable.image_name)* in your Picasso call like:
If you want to use a progress bar instead of a placeholder image you can create a callback inside the .into function. Do something similar to the following:
in your view:
In your adapter/class:
inside your adapter/class as above I create an inner class for the callback:
Hope this makes sense!
Its very simple to show the progress bar.
Add this code to the activity to load the image with progress bar.
Add this to your layout file.
You should setup your ProgressBar in addition to the Picasso library and you should manage the visibility of it manually using listeners.
I am using UniversalImageLoader and the Picasso library should be very similiar.
first create a drawable layout like this:
progress_animation.xml:
add
loading.png
to drawableUsage:
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.
Hope it will help someone! :)
Kotlin
The above code eliminates xml code and it's clean.