Android - Load Thumbnail from Website URL using Glide/Picasso

纵然是瞬间 提交于 2019-12-24 00:34:22

问题


  • I'm trying to load a thumbnail for an article on the web using Glide, but it returns an empty field.
  • Unlike other examples this URL does not directly link to a PNG/JPG etc, rather its a website link from which I require it to load the default thumbnail.
  • The ImageView has been set & initialised properly.
  • I have used Glide & Picasso in separate attempts, but it the ImageView is blank.

Snippet

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>

回答1:


You need to provide Glide/Picasso a direct link to article image. Try to find this site API, or use some "any website to API" tools, I believe it'll give you article image.



来源:https://stackoverflow.com/questions/38612896/android-load-thumbnail-from-website-url-using-glide-picasso

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!