Hi,
Are you still working with Image Loader or Universal Loader library for lazy loading of images in listview. if yes then you should know that sometimes these libraries could give out of memory exception if you are fetching lots of images or images of large size. But now Google introduced us an Image Loader Library for Android development named Glide. It succeeded in making me interested. I spent a some hours playing with it and decided to post this blog. As a beginning, I found it similar to Picassa but it wasn't.
It's bit simple to import in your Android studio by:
dependencies {
compile 'com.github.bumptech.glide:glide:3.5.2'
compile 'com.android.support:support-v4:22.0.0'
}
So with Glide you don't have to copy lots of files like you did with Image loader or universal loader. You have to write a single line like this :
Glide.with(context)
.load("ImagePathHere")
.into("ImageHere");
Here you to pass the Activity or Fragment to Glide not just a Context if possible.
Notes -
- You can change the format of your Image by setting GlideConfiguration class.
- You can resize the image by using override(300,300) property of Glide class.
- You can crop an image by using centerCrop() property.
- You can also set placeHolder and error image like.
.placeholder(R.drawable.placeholder)
.error(R.drawable.imagenotfound)
- The another intersting feature is to provide Gif image decoding for Animations.
0 Comment(s)