2013-04-09 76 views
8

如下图所示。第一张图片是在http://goldentrail.towardstech.com/assets/images/membersimage/buttons/eat.png链接的默认图片。而它下面的第二图像是使用UIL图片上的黑色背景加载了univerisal图片加载器

加载图像这是ImageLoader的配置

File cacheDir = StorageUtils.getCacheDirectory(context); 
    ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(context) 
      .memoryCacheExtraOptions(480, 800) // default = device screen dimensions 
      .discCacheExtraOptions(480, 800, CompressFormat.JPEG, 75) 
      .taskExecutor(AsyncTask.THREAD_POOL_EXECUTOR) 
      .taskExecutorForCachedImages(AsyncTask.THREAD_POOL_EXECUTOR) 
      .threadPoolSize(3) // default 
      .threadPriority(Thread.NORM_PRIORITY - 1) // default 
      .tasksProcessingOrder(QueueProcessingType.FIFO) // default 
      .denyCacheImageMultipleSizesInMemory() 
      .memoryCache(new LruMemoryCache(2 * 1024 * 1024)) 
      .memoryCacheSize(2 * 1024 * 1024) 
      .discCache(new UnlimitedDiscCache(cacheDir)) // default 
      .discCacheSize(50 * 1024 * 1024) 
      .discCacheFileCount(100) 
      .discCacheFileNameGenerator(new HashCodeFileNameGenerator()) // default 
      .imageDownloader(new BaseImageDownloader(context)) // default 
      .imageDecoder(new BaseImageDecoder()) // default 
      .defaultDisplayImageOptions(DisplayImageOptions.createSimple()) // default 
      .enableLogging() 
      .build(); 

这是displayoptions

DisplayImageOptions options = new DisplayImageOptions.Builder() 
    .bitmapConfig(Bitmap.Config.ARGB_8888) // default 
    .cacheInMemory() 
    .cacheOnDisc() 

    .build(); 

enter image description here

+0

你在ListView或GridView中显示图像吗?那么在这里展示您的RAW文件 – krishna 2013-04-09 05:58:05

+0

原始图像是在后http://goldentrail.towardstech.com/assets/images/membersimage/buttons/eat.png 的图像显示在滚动视图 – ericlee 2013-04-09 06:09:38

+0

任何帮助???? ??? – ericlee 2013-04-09 08:33:02

回答

14

你看到评论in自述:

DON'T COPY THIS CODE TO YOUR PROJECT! This is just example of ALL options using. 

请勿使用.discCacheExtraOptions(480, 800, CompressFormat.JPEG, 75)。 您的图像以JPEG文件的形式保存在光盘缓存中,该文件不能具有透明背景。

+0

是的,如果您使用PNG,请尝试'.discCacheExtraOptions(480,800,CompressFormat.PNG,75,null)'。否则禁用缓存。 – Muz 2014-01-20 05:29:25

+0

不工作我为nostra和@Muz我的代码:http://pastie.org/9263301 – berserk 2014-06-06 07:05:34

+0

对不起,我忘了卸载应用程序。它从缓存中获取图像。 – berserk 2014-06-06 07:15:27

0

尝试使用android-query。这个API有助于图像,而其他一些可以与android一起使用。