是否可以使用Glide下载图像以加载到TextView中? [英] Is it possible to use Glide to download image to load into a TextView?
本文介绍了是否可以使用Glide下载图像以加载到TextView中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在我的应用程序中,我从URL下载图像并将其通过Glide设置为ImageView,但是,我试图删除一些不必要的布局,因此可以使用Glide下载图像并将其设置为TextView?
In my app I download an image from an URL and set it into an ImageView through Glide, however, I'm trying to remove a few unnecessary layouts, so is it possible to use Glide to download an image and set into to TextView?
try {
Glide.with(holder.logo.getContext())
.load(standingObjectItems.get(position).getImgId()).diskCacheStrategy(DiskCacheStrategy.ALL)
.error(R.mipmap.ic_launcher)
.placeholder(R.mipmap.ic_launcher)
.into(holder.logo);
} catch (IllegalArgumentException | IndexOutOfBoundsException e) {
e.printStackTrace();
}
推荐答案
Glide.with(left.getContext())
.load(((FixturesListObject) object).getHomeIcon())
.asBitmap()
.into(new SimpleTarget<Bitmap>(100,100) {
@Override
public void onResourceReady(Bitmap resource, GlideAnimation glideAnimation) {
left.setCompoundDrawablesWithIntrinsicBounds(null, new BitmapDrawable(left.getResources(),resource), null, null);
}
});
这篇关于是否可以使用Glide下载图像以加载到TextView中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文