为什么我的图片在使用 glide 库加载后会缩小 [英] Why do my images shrink after loading with glide library

查看:80
本文介绍了为什么我的图片在使用 glide 库加载后会缩小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当它们第一次被调用到我的片段中时,我正在使用滑翔图像加载器库填充 gridview,它们看起来像这样 但是在上下滚动后,它们被调整大小,看起来像这样 这是我正在用我的 gridview、glide 库做的事情,还是像我的占位符图像这样的东西?在第二个屏幕截图上如果我按下一个图像,它会亮起以表明它实际上填满了整个空间,有人知道我在这里做错了什么吗?我已经尝试过使用 centercrop 等更改 glide 中的调用,但似乎没有区别,我不确定如何计算每个单元格的宽度和高度,欢迎提出任何建议

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);

推荐答案

实际上你必须给你的图像容器(ImageView)固定宽度和高度.

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" />

然后,当您调用 glide 时,您必须使用 override 方法动态覆盖您的宽度和高度.这是容器的最大宽度和高度.

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);

希望能帮到你.

这篇关于为什么我的图片在使用 glide 库加载后会缩小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆