加载滑行库后,为什么我的图像会缩小 [英] Why do my images shrink after loading with glide library

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

问题描述

你好我正在用glide图像加载器库填充gridview,当他们第一次被调用到我的片段中时,它们看起来像这样
但是在上下滚动之后,它们会被调整大小并显示像这样
这是我用GridView,滑翔库做的事,还是像我的占位符图像那样的东西?在第二个屏幕截图上如果我点击一张图片,它会点亮以显示它实际上正在填充整个空间,任何人都知道我在这里做错了什么?我尝试改变滑动呼叫与centercrop等这样的呼叫,但它似乎没有什么区别,我不知道我将如何解决每个单元格的宽度和高度,欢迎任何建议

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

编辑
这里是我如何调用glide

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

希望这可以帮到你。

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

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