Image scaling horizontally using override does not resize image

I use Glide to download and display the image, however, when I tried to resize the image, it does not. I get a random size (or maybe its actual image size).

Here is the code I used to download through Glide

Glide.with(context) .load(file.getUrl()) .asBitmap() .diskCacheStrategy(DiskCacheStrategy.ALL) .centerCrop() .transform(new CropCircleTransform(context)) .override(dimen, dimen) .into(new SimpleTarget<Bitmap>() { @Override public void onResourceReady(Bitmap resource, GlideAnimation<? super Bitmap> glideAnimation) { bitmap = resource; Log.info(resource.getWidth() + "x" + resource.getHeight()); } }); 

the CropCircleTransform simply displays the circular and central cropping of the bitmap. I tried to remove it simply to check if this method caused a problem, but still the image does not change to fit the specified size.

Is there something wrong with my code? or i don't understand the override method here?

EDIT:
Tried to remove the redefinition and seems to have uploaded the image in large sizes, so this means that the actual resizing occurs when using the override.

Why doesn't it resize the actual value that I specified?

EDIT:
As a sample, the value for dimen is 96, but the size displayed in the log for images is 97x97, 117x117, 154x154, etc.

Does this mean that the value for the override method is the base value for the resize, and not the actual dimension that will be used?

+6
source share
3 answers

I meet this error only now. My solution is given an image as follows:

  • set the image size in the xml file.
  • Glide.with(context).load(path).centerCrop().crossFade().into(imageview);

it works.

+1
source

I just met the same situation. And I think this is a Glide bug. Therefore, you need to resize the bitmap as follows:

 Glide.with(context).load(url).asBitmap().into(new SimpleTarget<Bitmap>{ @Override public void onResourceReady(Bitmap resource,GlideAnimation<? extends Bitmap>(){ // resize the bitmap bitmap = resize(width,height); imageView.setImageBitmap(bitmap); } }) 

By the way, scaleType ImageView, such as 'fitXY', 'centerCrop', 'fitCenter', etc., can also affect how Glide resizes the image.

0
source

`ImageView iv = (ImageView) findViewById (R.id.left);

int width = 60; int height = 60;

LinearLayout.LayoutParams parms = new LinearLayout.LayoutParams (width, height); iv.setLayoutParams (Parms);

Glide.with (context) .load (path) .centerCrop () CROSSFADE () in (IV); .. `

0
source

All Articles