Updated 18 August 2017
There are many libraries where we can load an URL Image. for Ex. Glide, Picasso.
Here we use Picasso Library.
What is Picasso Library?
A powerful image downloading and caching Library for Android. By its use Developer, to load an image in “android application” with one line of code, without worry about caching, transformation and threading an image to load.
Add dependency in the “build.gradle” file.
1 |
compile"com.squareup.picasso:picasso:2.4.0" |
For more details please click the following link-
https://mobikul.com/picasso-library-use-image-loading-android/
How to animate image after image loaded from Server?
Just add animation when image completely downloaded from URL in Picasso callback Listener.
1 2 3 4 5 6 7 |
if (imageUrl != null && !imageUrl.equalsIgnoreCase("")) { Picasso.with(view.getContext()) .load(imageUrl) .placeholder(R.drawable.placeholder) .transform(new BitmapTransform(Utils.getScreenWidth() .into(view, utils.getCallBack(view)); } |
Here our animation function that returns Picasso Callback Listener object-
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
public Callback getCallBack(final ImageView imageView) { return new Callback() { @Override public void onSuccess() { ScaleAnimation scale = new ScaleAnimation(0, 1, 0, 1, ScaleAnimation.RELATIVE_TO_SELF, .75f, ScaleAnimation.RELATIVE_TO_SELF, .75f); scale.setDuration(400); imageView.startAnimation(scale); } @Override public void onError() { } }; } |
If you have more details or questions, you can reply to the received confirmation email.
Back to Home
Be the first to comment.