i use the following code to load an image with rounded corners into imageview using glide:
Glide.with(this)
.load(url)
.listener(new RequestListener<Drawable>() {
@Override
public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Drawable> target, boolean isFirstResource) {
return false;
}
@Override
public boolean onResourceReady(Drawable resource, Object model, Target<Drawable> target, DataSource dataSource, boolean isFirstResource) {
return false;
}
})
.transition(withCrossFade())
.apply(new RequestOptions().transform(new RoundedCorners(50)).error(R.drawable.default_person).skipMemoryCache(true).diskCacheStrategy(DiskCacheStrategy.NONE))
.into(mBinding.profileImgv);
images get pixelized for some reason. Can somebody tell me where is the problem?
circleCrop() . into(imageView); Glide V3: You can use RoundedBitmapDrawable for circular images with Glide.
I had the same issue, the problem in my case was the image what i've tried to load had less size in pixels (320x480), then the ImageView size in pixels. My solution was the following:
My ImageView in the xml file:
<ImageView
android:id="@+id/image_program_thumb"
android:layout_width="match_parent"
android:layout_height="186dp" />
ProgramViewHolder.java class
@BindView(R.id.image_program_thumb) ImageView mProgramThumbnail;
.....
void bindData(final Program item) {
RequestOptions requestOptions = new RequestOptions();
requestOptions = requestOptions.transforms(new CenterCrop(), new RoundedCorners(16));
Glide.with(itemView.getContext())
.load(item.getImage())
.apply(requestOptions)
.into(mProgramThumbnail);
....
}
P.S. I use 4.2.0 version of Glide
in Glide V4
Try like this
Glide.with(this.context)
.load(url)
.apply(RequestOptions.bitmapTransform(new RoundedCorners(14)))
.into(ImageView);
For Glide v4.9 transformation (java):
Glide.with(this)
.load(R.drawable.sample)
.transform(new CenterCrop(),new RoundedCorners(25))
.into(image);
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