在Imageview中使用Glide加载图像 [英] Loading images using Glide in Imageview

查看:575
本文介绍了在Imageview中使用Glide加载图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Glide库在imageview中加载图片并使用以下代码。

I am using Glide library for loading images in imageview and using the below code.

Glide.with(mActivity)
                .load(img.getmGridViewImageUrl())
                .placeholder(R.color.grey_light)
                .into(imageHolder.imageView);

灰色的占位符在图像未加载之前可见,但在图像加载到imageview之后,占位符仍然存在,并在该图像后显示一些空格。

The placeholder with grey color gets visible until the image does not load but after the image get loads in imageview, the placeholder still take place and show some blank space after that image.

如何解决此问题。如果你有任何想法,请帮帮我。

How can I resolve this issue. Please help me if you have any idea here.

推荐答案

试试这个代码。

当我给 ImageView 提供修复高度时,它适用于我。

When I give fix height to the ImageView it works for me.

这是布局

<ImageView 
    android:id="@+id/imgPoster"
    android:layout_width="fill_parent"
    android:layout_height="@dimen/height_of_getInspired_list"
    android:layout_centerVertical="true"
    android:scaleType="fitXY" 
    android:src="@drawable/default_image"/>

这是我的代码。

Glide.with(this.context).load(inspiredList.get(position).image)
.error(R.drawable.default_image)
.centerCrop()
.crossFade()
.placeholder(R.drawable.default_image).into(holder.imgPoster);

这篇关于在Imageview中使用Glide加载图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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