![]() |
VOOZH | about |
COIL is an acronym for Coroutine Image Loader. COIL is one of the famous image loading libraries from URLs in Android. It is a modern library for loading images from the server. This library is used to load images from servers, assets folder as well as from the drawable folder in Android project. The important feature of this library is that it is fast, lightweight, and easy to use. In this article, we will see How to Use this Image Loader Library in Android Apps.
COIL Image loading library is provided by Kotlin Coroutines which is used for loading images in Android. This library is specially designed for loading images in Kotlin. It is modern, easy to use, lightweight, and fast for loading images from the server. This is the new library and provides new optimization for loading images from the server very efficiently. As Kotlin is now been officially announced as the preferred language for Android development, that's why for loading images we should prefer using COIL for loading images in Android.
To create a new project in Android Studio please refer to How to Create/Start a New Project in Android Studio.
Note that select Kotlin as the programming language.
Navigate to gradle scripts and then to build.gradle(Module) level. Add below line in build.gradle file in the dependencies section.
implementation("io.coil-kt.coil3:coil:3.0.4")
implementation("io.coil-kt.coil3:coil-network-okhttp:3.0.4")
After adding dependency click on the "sync now" option on the top right corner to sync the project.
Navigate to the app > Manifest to open the Manifest file. In the manifest file, we are adding internet permission to load images from the internet.
Add the following lines in your manifest file.
<uses-permission android:name="android.permission.INTERNET" />Navigate to the app > res > layout to open the activity_main.xml file. Below is the code for the activity_main.xml file.
Go to the MainActivity.kt file and refer to the following code. Comments are added inside the code to understand the code in more detail.