无法使用通用的图像加载器来设置图像视图的背景图片? [英] Unable to set image view background image using universal image loader?

查看:329
本文介绍了无法使用通用的图像加载器来设置图像视图的背景图片?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图设置图像视图背景。但没有得到运气用通用图像加载器来设置背景。

I am trying to set background for the image view. But not got luck to set background using universal image loader.

我使用以下code。

DisplayImageOptions options = new DisplayImageOptions.Builder()
                                    .showStubImage(R.drawable.mo_no_image)
                                    .showImageForEmptyUri(R.drawable.mo_no_image)
                                    .cacheInMemory().cacheOnDisc()
                                    .displayer(new RoundedBitmapDisplayer(0))
                                    .imageScaleType(ImageScaleType.EXACTLY).build();
ImageLoader.getInstance().displayImage("url_to_load_image", imgView, options);

通过使用上述code,我能够设置图像资源检查其长宽比和使用修改图片大小。
        我想下载的图像设定为图像视图的背景。

By using above code I am able to set image resource which check aspect ratio and using that modifying image size. I want to set downloaded image to the background of image view.

推荐答案

我可以推荐的作品就像一个魅力不同的方法:Android的查询

I can recommend a different way that works like a charm: Android Query.

您可以从 HTTP下载jar文件$ c.google.com / p / Android的查询/下载/列表

AQuery androidAQuery=new AQuery(this);

作为一个例子:

androidAQuery.id(YOUR IMAGEVIEW).image(YOUR IMAGE TO LOAD, true, true, getDeviceWidth(), ANY DEFAULT IMAGE YOU WANT TO SHOW);

这是非常快速和准确,并利用这个你可以加载时找到更多的功能,如动画;得到的位图,如果需要的话;等等。

It's very fast and accurate, and using this you can find many more features like Animation when loading; getting a bitmap, if needed; etc.

在你的情况,你需要获取位图,所以对于它,请使用以下code

In your case you need to fetch Bitmap, so for it, use below code

androidAQuery.ajax(YOUR IMAGE URL,Bitmap.class,0,new AjaxCallback<Bitmap>(){
                        @Override
                        public void callback(String url, Bitmap object, AjaxStatus status) {
                            super.callback(url, object, status);

                            //You will get Bitmap from object.
                        }

});

使用此位图来设置ImageView的使用方法,你的背景资源。

Use this bitmap to set your background resource of ImageView using method.

这篇关于无法使用通用的图像加载器来设置图像视图的背景图片?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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