【问题标题】:Black Background on image loaded with univerisal image loader使用通用图像加载器加载的图像上的黑色背景
【发布时间】:2013-03-31 10:17:22
【问题描述】:

如下图。第一个图像是链接在http://goldentrail.towardstech.com/assets/images/membersimage/buttons/eat.png 的默认图像。而它下面的第二张图片是使用 uil 加载的图片

这是图像加载器配置

    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();

这是显示选项

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

    .build();

【问题讨论】:

  • 您是在 ListView 还是 GridView 中显示图像?然后在此处显示您的原始文件

标签: android universal-image-loader


【解决方案1】:

您是否在自述文件中看到评论:

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

不要使用.discCacheExtraOptions(480, 800, CompressFormat.JPEG, 75)。 您在磁盘缓存中保存的图像为 JPEG 文件,不能有透明背景。

【讨论】:

  • 是的,如果你使用 PNG,试试 .discCacheExtraOptions(480, 800, CompressFormat.PNG, 75, null) 之类的东西。否则禁用缓存。
  • 对不起,我忘了卸载应用程序。它正在从缓存中获取图像。
  • 现在已弃用,有什么解决方法吗? (UIL 中甚至没有 CompressFormat 类)
【解决方案2】:

尝试使用android-query。此 API 有助于处理图像,而其他一些 API 则适用于 android。

【讨论】:

    猜你喜欢
    • 2012-04-19
    • 2014-03-23
    • 1970-01-01
    • 2011-11-03
    • 1970-01-01
    • 2014-01-24
    • 1970-01-01
    • 2021-12-29
    • 2017-05-01
    相关资源
    最近更新 更多