I am using glide library to load image url in image view.
Glide.with(context)
.load(imageurl)
.apply(RequestOptions.circleCropTransform())
.into(holder.thumbnail);
Actually, the image is loaded fine with rounded image.
I need the image to be loaded with rounded + grayscale image
Can this be done by using glide lib?
You can use Android's android.graphics.ColorMatrix class to set the saturation to 0 for making an ImageView grayscale.
You can achieve what you want in two steps. 1. Use Glide to make the ImageView rounded. 2. After that use ColorMatrix class to make the ImageView grayscale.
Glide.with(context)
.load(imageurl)
.apply(RequestOptions.circleCropTransform())
.into(holder.thumbnail);
ColorMatrix colorMatrix = new ColorMatrix();
colorMatrix.setSaturation(0);
ColorMatrixColorFilter filter = new ColorMatrixColorFilter(colorMatrix);
holder.thumbnail.setColorFilter(filter);
If you are using Kotlin:
//Grey scale
val colorMatrix = ColorMatrix();
colorMatrix.setSaturation(0.0f);
val filter = ColorMatrixColorFilter(colorMatrix);
itemView.thumb.colorFilter = filter;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With