Yes, we have new image display library call glide. Glide is the perfect and best one to use compared to Picasso and Fresco.
Reasons of using Glide:
- Recommended by Google and has been used in many Google open source projects.
- Picasso loads the full-size image (1920x1080 pixels) into the memory and let GPU does the real-time resizing when drawn. While Glide loads the exact ImageView-size (768x432 pixels) into the memory which is a best practice.
- Glide cache both the full-size image and the resized one. Picasso will cache only single size of image, the full-size one. Glide acts differently, caches separate file for each size of ImageView.
- GIF (animated image) support.
- In addition, it also helps preventing an app from popular OutOfMemoryError.
Fresco has huge size of library and cache also. Moreover, app freezes while loading big images from internet into ListView.
While Glide has small size of both library and cache.(Source: Quora)
Here is the pictorial difference between Glide vs Picasso vs Fresco.
Now, How to use Glide to display images on Android, Here is the simple steps,
First you have to introduces dependencies on gradle.
compile 'com.github.bumptech.glide:glide:3.5.2'
and
On your imageview, please provide this code for display images.
image is image view , depend you requirement,
In kotlin:
val image = currentView.findViewById(R.id.image) as ImageView |
In Java
ImageView image= (ImageView) findViewById(R.id.image)
Now, render the image url on our imageview.
Glide.with(context) |
.load(currentVolume.imageUrl) |
.into(image)
#HappyCoding #ILoveKotlin