Hi I'm populating a gridview with glide image loader library when they first get called into my fragment they look like this But after scrolling up and down they are resized and look like this Is this something I'm doing with my gridview, the glide library, or is it something else like my placeholder image? on the second screenshot If I press on an image it lights up to show it is in actual fact filling that whole space, anyone know what I'm doing wrong here? I've tried changing the call in glide playing with centercrop and such but it seems to make no difference, I'm not sure how I would work out the width and height of each cell, any suggestions welcome
EDIT here is how im calling glide
Glide.with(getActivity())
.load(mThumbIds[position])
.placeholder(R.drawable.placeholder)
.error(R.drawable.ic_drawer)
.centerCrop()
.override(500,300)
.into(imageView);
Add an explicit width or height to the ImageView by setting layout_width=500dp in the layout file. Call . override(width, height) during the Glide load and explicitly set a width or height for the image such as: GlideApp.
Image Resizing with override(x, y) Glide automatically limits the size of the image it holds in cache and memory to the ImageView dimensions.
If a loaded image happens to be smaller than the ImageView, Glide will unnecessarily expand original bitmap to match the size of the target view. One way to prevent it is to set scaleType=”centerInside” in the ImageView. That way loaded image won't expand beyond the original size.
Glide is an Image Loader Library for Android developed by bumptech and is a library that is recommended by Google. It has been used in many Google open source projects including Google I/O 2014 official application. It provides animated GIF support and handles image loading/caching.
Actually you have to give fix width and height to your image container(ImageView).
<ImageView
android:id="@+id/channelImage"
android:layout_width="65dp"
android:layout_height="65dp"
android:layout_centerHorizontal="true"
android:layout_margin="10dp"
android:src="@drawable/sama" />
Then when you call glide you have to override your width and height dynamically with override method. This is maximum Width and height for you container.
Glide.with(getActivity())
.load("your url")
.placeholder(R.drawable.tv2v_icon)
.diskCacheStrategy(DiskCacheStrategy.ALL)
.fitCenter()
.override(500,500)
.into(channelImage);
hope this can help you.
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