Imageview download image with Glide or Picasso

2
  

Is Glide or Picasso used with local resources?

I have an imageview in a recycler that is also a shared item with an activity detail.

  

How do I upload that image in the imageview with Glide or Picasso?

    
asked by Carlos 25.05.2017 в 13:11
source

1 answer

0

Upload image with Glide or Picasso.

Glide With glide, it is done in a similar way:

   Glide.with(context).load(R.drawable.android).into(imageView);

adding the dependency within your build.gradle file:

dependencies {
    ...
    compile 'com.github.bumptech.glide:glide:3.7.0'
    ...
}

Picasso: With Picasso you can upload images defined in the resources for example an image called android.jpg within /drawable :

ImageView imageView = (ImageView) findViewById(R.id.imageView);
Picasso.with(context).load(R.drawable.android).into(imageView);

adding the respective dependency within your file build.gradle :

dependencies {
    ...
   compile 'com.squareup.picasso:picasso:2.5.2'
    ...
}

with both options you would have the same result:

Image from a URL

You can also download an image from an url, in this case instead of the reference to the directory /drawable a url is defined:

Glide:

  Glide.with(context).load(imageUrl).into(imageView);

Picasso:

Picasso.with(context).load(imageUrl).into(imageView);
    
answered by 25.05.2017 / 16:27
source