【问题标题】:Picasso setting placeholder image but not the actual image毕加索设置占位符图像而不是实际图像
【发布时间】:2019-07-13 08:43:57
【问题描述】:

我正在使用 android 上的 Picasso 库来显示个人资料图片,但由于某种原因图片无法加载,并且应用只显示占位符图片。

Picasso.get()
            .load(R.drawable.ic_person_black_100dp)
            .placeholder(R.drawable.common_full_open_on_phone)
            .into(profileImageView);

【问题讨论】:

  • 如果您从本地资源获取,为什么需要占位符?
  • @makata 最初我写的代码没有占位符,但图像没有加载,所以我尝试添加占位符,我意识到应用程序正在加载占位符而不是图像
  • ic_person_black_100dp 是可绘制的矢量吗?
  • @makata 是的
  • 不支持矢量绘图。关注this线程了解更多

标签: android android-imageview picasso


【解决方案1】:

Picasso 2.X 不支持矢量绘图。您可以使用 Glide 或使用解决方法:

Glide.with(context)
   .load(R.drawable.my_vector_drawable)
   .into(mImageView);

当 load() 调用失败时,Picasso 的错误处理机制似乎适用于矢量可绘制对象:

Picasso.get()
    .load(R.drawable.my_vector_drawable)
    .error(R.drawable.my_vector_drawable)
    .into(mImageView);

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-12-07
    • 2018-01-21
    • 1970-01-01
    • 1970-01-01
    • 2019-07-31
    相关资源
    最近更新 更多