【问题标题】:Universal Image Loader gets image but output appears blank通用图像加载器获取图像但输出显示为空白
【发布时间】:2018-05-24 23:45:44
【问题描述】:

我在 DropBox 的共享文件夹中有一张图片。我已将 Universal Image Loader 加载到我的应用程序中,我正在尝试从共享文件夹中提取图像并将其显示在图像视图中。一切似乎都在工作,除了显示图像时,我得到的只是一个白屏。

String fileURL = "https://www.dropbox.com/s/(obfuscated)/stripad.jpg";

ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(this).build();
ImageLoader imageLoader = ImageLoader.getInstance();
imageLoader.init(config);

ImageView imageview = (ImageView)findViewById(R.id.adtest1);
DisplayImageOptions options = new DisplayImageOptions.Builder()
        .imageScaleType(ImageScaleType.EXACTLY_STRETCHED)
        .cacheInMemory(true)
        .bitmapConfig(Bitmap.Config.RGB_565)
        .build();
imageLoader.displayImage(fileURL, imageview, options);

我的 XML 是这样的:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".DropBoxTest">

    <ImageView
        android:id="@+id/adtest1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"
        />

</RelativeLayout>

我不知道出了什么问题。我没有收到任何错误,并且 LogCat 是空的。我已经尝试过 .PNG 和 .JPG 图像,两种类型的行为都相同。我可以在浏览器中手动导航到 fileURL 并毫无问题地查看图像。

【问题讨论】:

    标签: android universal-image-loader


    【解决方案1】:

    您提供的网址有误。您所拥有的不是图像的直接网址,Dropbox 将其重定向到网页,因此无法将其解码为图像。 我从该页面中提取了一个替代网址,并且它有效。试试这个:

    https://photos-5.dropbox.com/t/2/AABK87ma_5R3iq0CcE0KJD-UzdevZ6-khx0Qr6_msAPFPw/12/442547683/jpeg/32x32/3/1527224400/0/2/stripteaserad.jpg/EPmz9MgDGPUQIAcoBw/h_Pb1ngZ6KBY9w5bqERmy6ouX--cPSFaExdsGsqJiQ8?dl=0&size=2048x1536&size_mode=3

    您需要找到合适的托管服务。

    附:顺便说一句,您的 URL 是一次有风险的点击

    【讨论】:

    • 非常有意义。感谢您的回答!
    猜你喜欢
    • 2015-11-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-07-14
    • 2014-11-27
    • 1970-01-01
    • 2013-05-20
    • 2014-02-10
    相关资源
    最近更新 更多