Universal Image Loader不能正确显示来自Web的图像

时间:2014-09-19 06:12:14

标签: android universal-image-loader

我的应用程序使用Universal Image Loader显示网址图像。但是,图像不会完全显示。即使我将ImageView的缩放类型设置为centerCrop,它也只显示部分图像。 我已经检查过图像在互联网浏览器中完美显示。

在PagerAdapter中,我将图像设置为显示

@Override
public Object instantiateItem(View container, int position) {
    LayoutInflater inflater = (LayoutInflater) container.getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View view = inflater.inflate(R.layout.layout_pager_image, null);
    image = (ImageView) view.findViewById(R.id.imageView1); 
    imageLoader.displayImage(mItems.get(position).imageurl, image);

    ((ViewPager) container).addView(view, 0);

    return view;
}

有关更多信息,请配置ImageLoader,

    public static void initImageLoader(Context context) {
    // This configuration tuning is custom. You can tune every option, you may tune some of them,
    // or you can create default configuration by
    //  ImageLoaderConfiguration.createDefault(this);
    // method.
    DisplayImageOptions options = new DisplayImageOptions.Builder()
    .showImageOnLoading(R.drawable.transparent)
    .showImageForEmptyUri(R.drawable.ic_launcher)
    .showImageOnFail(R.drawable.ic_launcher)
    .cacheInMemory(true)
    .cacheOnDisc(true)
    .bitmapConfig(Bitmap.Config.RGB_565)//
    .imageScaleType(ImageScaleType.IN_SAMPLE_INT)//
    .considerExifParams(true)
    .build();

    ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(context)
            .threadPriority(Thread.NORM_PRIORITY - 2)
            .denyCacheImageMultipleSizesInMemory()
            .discCacheFileNameGenerator(new Md5FileNameGenerator())
            .tasksProcessingOrder(QueueProcessingType.LIFO)
            .writeDebugLogs() // Remove for release app
            .defaultDisplayImageOptions(options)
            .build();
    // Initialize ImageLoader with configuration.
    ImageLoader.getInstance().init(config);
}

请帮忙!

0 个答案:

没有答案