【问题标题】:Android - Load Thumbnail from Website URL using Glide/PicassoAndroid - 使用 Glide/Picasso 从网站 URL 加载缩略图
【发布时间】:2016-12-01 11:02:57
【问题描述】:
  • 我正在尝试使用 Glide 为网络上的一篇文章加载缩略图, 但它返回一个空字段。
  • 与其他示例不同,此 URL 不直接链接到 PNG/JPG 等等,而不是它的网站链接,我要求它从中加载 默认缩略图。
  • ImageView 已正确设置和初始化。
  • 我曾多次尝试使用 Glide & Picasso,但它 ImageView 为空白。

片段

ivGlide = (ImageView) findViewById(R.id.ivGlide);

String uriLoad = "http://www.recode.net/2016/7/26/12281110/facebook-video-360-degree-camera";

//USING GLIDE
Glide.with(Activity_glidetest.this)
.load(uriLoad) 
.centerCrop()
.into(ivGlide);

    //USING PICASSO
    Picasso.with(Activity_frienddetail.this)
    .load(uriLoad)
    .resize(78, 78)
    .centerCrop()
    .into(ivGlide);

XML

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >

    <ImageView
        android:id="@+id/ivGlide"
        android:layout_width="78dp"
        android:layout_height="78dp"
        android:src="@drawable/hand"
        android:layout_centerInParent="true" />

</RelativeLayout>

【问题讨论】:

  • 你是否在 manifest 中提供了
  • 该 url 不是图像 url,您应该将图像 url 传递给 Glide/Picasso
  • @Chol 如何从网站链接中检索图像 url?
  • 不知道...在源代码页面你可以在这里找到它 cdn3.vox-cdn.com/thumbor/GpZwP7N6W04JFl2bcA9fDF6gv6o=/…" />

标签: android imageview picasso android-glide


【解决方案1】:

您需要向 Glide/Picasso 提供文章图片的直接链接。尝试找到这个站点API,或者使用一些“任何网站到API”的工具,我相信它会给你文章图片。

【讨论】:

  • 有什么代码可以分享给 Android 吗?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-09-18
  • 2018-07-14
  • 2022-01-01
  • 2018-07-06
  • 2021-08-03
  • 1970-01-01
相关资源
最近更新 更多