If you are also a Glide lover like me, then you should look over the features of COIL.
Recently I came across this image loading library Coil which I saw was gaining much popularity. I was more curious because I was thinking about how it's giving competition to a library like Glide. And so I wanted to share my findings with you guys in a very summarized and a quick way! So without wasting any time, let's jump over its features.
Brief introduction to Coil๐ฃ๏ธ
Coil, according to their official documentation, stands for COroutine Image Loader, which is owned by Kotlin Coroutines (If you are not aware of Coroutines then refer this).
Key Features ๐ฅ
As we are moving towards modern android development practices, its important to keep ourselves updated with new tools and libraries. The points for which you can consider Coil over the most loved libraries like Glide, Picasso, or maybe Universal Image Loader(famously known as UIL) are:
- Coil is light weighted. The library size is much less than Glide or other such libraries. (Coil - 94 Kb whereas Glide - 222 Kb and Fresco is 244 Kb).
- It's very easy to use. As far as features are compared, Coil provides so many features, and it's so easy to use that a very beginner can easily implement this library.
Fast forwarding to its Implementation ๐งโ๐ป
Add the dependencies on your gradle file:
implementation("io.coil-kt:coil:2.1.0")
Now simply bind the image to your imageView as follows:
From a drawable:
imageview.load(R.drawable.blog_image)
From a Network:
imageview.load("https://blog-image.jpg")
From a File:
imageview.load(File("/path/to/blog-image.jpg"))
Thats it, So simple right ๐
Here this load() function is used to load the image to the imageView.
More features ๐คฉ
The functionality is not limited to load(). We can also extend this functions with lambda as shown below:
imageView.load("https://blog-image.jpg") {
crossfade(true)
placeholder(R.drawable.blog_image)
transformations(CircleCropTransformation())
}
Want to know more about the Coil Usage and How to use it with jetpack Compose then Refer this.
So now you can compare how simple this library is as compared to Glide, or Picasso which has those long syntax like : Glide.with().load().into(). First provide the context, then the image then the view ๐ช.
So what are you waiting for, just rush into your android studio and use Coil in your project ๐.
Hope you will enjoy reading this.
Thanks for reading.