Glide compresses the image on first boot

When I load an image into ImageView using Glide , it compresses the image. When I rotate or rediscover the same activity, it is the right size. I have already tried a possible duplicate . I already pass the patch size to ImageView inside xml and I also tried to override the size. centerCrop() and fitCenter() do not affect shrinkage. I also tried to debug image size. When it is compressed or not, it returns the same width and height.

View:

 <ImageView android:id="@+id/thumbnail" android:layout_width="@dimen/episode_detail_img_width" android:layout_height="@dimen/episode_detail_img_height" android:layout_marginTop="@dimen/episode_detail_img_margin_top" /> 

Glide

 Glide.with(getActivity()) .load(url) .placeholder(R.drawable.thumb_placeholder) .centerCrop() .diskCacheStrategy(DiskCacheStrategy.ALL) .into(thumbnail); 
+7
android android-glide
source share
4 answers

I'll make sure you get your answer. but for a more detailed description of your problem:

Sliding calculates the height and level of the ImageView image before loading the image, but when the image gets loaded, it replaces your place holder. therefore, if your size or the weight of your placement is small, Glide will display the loaded bitmap with a placeholder size.

Thus, without lag in different screen sizes and layout, I recommend using a high size that can be cut in placeholder.

And another hack is to use color in the placeholder. The bcoz color has no height or width, so render the entire viewing area.

+11
source share

This can be fixed:

1) add .dontAnimate ()

2) find the placeholder matching the image coefficient

Explanation: https://github.com/bumptech/glide/issues/1295

The first time the image loads the default values ​​.crossFade () and the aspect ratio of your placement does not match the downloaded images, the ratio is. The second time the image is loaded from the memory cache and the animations are skipped in this case, which leads to a simple image loading properly You can turn off the animation via .dontAnimate () or force the .animate animation (R.anim.fade_in) to be activated, or find which corresponds to the ratio of the images (ie the square in your case, because of 512x512).

+1
source share

Compared to Picasso, Glide is much more memory efficient. Glide automatically limits image size stored in cache and memory to ImageView

Clean your project and try this code:

 Glide .with(context) .load(url) .override(400, 200) // resizes the image to these dimensions (in pixel).does not respect aspect ratio .into(thumbnail); 
0
source share

You have defined the placeHolder () method, which will be loaded at the initial moment of time, and when the glide path loads the image based on the given URL, then move the Loaded Image with the placeHolder image. which will appear in imageView. This is an uploaded image set to imageView based on the specified method.

e.g. cropCenter (), fitCenter (), etc.

do not use cropCenter (), it will crop the image from the center and place it in your View image so that the image quality disappears.

use fitCenter () method.

 <ImageView android:id="@+id/conversation_team_photo" android:layout_width="56dp" android:layout_height="56dp" android:scaleType="fitCenter" /> 

and I determined the way bast use glide here is the best way to use glide.

0
source share

All Articles