简体   繁体   English

毕加索-下载图片一次,然后加载到多个ImageView中

[英]Picasso - Download image once then load into multiple ImageView

Does anyone know how to download an image once then use the same Picasso instance to load into multiple ImageView ? 有谁知道如何一次下载图像然后使用相同的Picasso实例加载到多个ImageView Right now I'm using a (pretty bad) workaround like the one below, in order to be sure the image is already cached and not downloaded again. 现在,我正在使用一种(非常糟糕的)替代方法,如下所示,以确保该图像已被缓存并且不会再次下载。

Picasso.with(container.getContext()).load(photo.getPath()).placeholder(R.drawable.placeholder_outfit).fit().centerCrop().into(image1, new Callback() {
    @Override
    public void onSuccess() {
        Picasso.with(container.getContext()).load(photo.getPath()).placeholder(R.drawable.placeholder_outfit).fit().centerCrop().into(image2);
    }

    @Override
    public void onError() {

    }
});

You can do it like this: 您可以这样做:

    Picasso.with(container.getContext())
        .load(photo.getPath())
        .placeholder(R.drawable.placeholder_outfit)
        .fit()
        .centerCrop().into(image1, new Callback() {

          @Override
          public void onSuccess() {
              imageView2.setImageDrawable(image1.getDrawable()); //Get the ImageView's image (this won't download it, it will get the downloaded image) and set it to your second imageView.
          }

          @Override
          public void onError() {

          }
        });

To use centerCrop() , just add: 要使用centerCrop() ,只需添加:

imageView2.setScaleType(ImageView.ScaleType.CENTER_CROP);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用Picasso将图像加载到ImageView中 - Load Image into ImageView using Picasso 毕加索不会将可绘制图像加载到ImageView中 - Picasso doesn't load drawable image into ImageView Android Picasso不会将所有图像加载到imageview - Android Picasso does not load all image to imageview 将带有毕加索的位图加载到ImageView中 - Load bitmap with picasso into ImageView 使用Android中的Picasso图像加载器库将受密码保护的图像加载到imageview - Load password protected image to imageview with Picasso Image loader Library in android 使用毕加索将图像加载到以编程方式添加的ImageView中[不工作] - Use Picasso to load image into programmatically added ImageView [NOT WORKING] 使用毕加索将图像从url加载到gridview中的imageview中 - load image from url to imageview in a gridview using picasso 如何使用Picasso或Glide库将图像字符串路径加载到ImageView中? - How to load image string path into an ImageView using Picasso or Glide library? 将Picasa从Firebase存储中的图像加载到Infowindow中的ImageView中,Picasso仅显示占位符 - Load Image from Firebase Storage with Picasso to ImageView in Infowindow, Picasso only shows placeholder Android - 使用毕加索将Byte []加载到imageview中 - Android - load Byte[] into imageview with picasso
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM