【问题标题】:Image transformation not applied after orientation change with Picasso使用毕加索改变方向后未应用图像变换
【发布时间】:2015-03-04 18:34:16
【问题描述】:

我正在使用 Picasso 和 RoundedTransformation class,它将圆角应用于我使用 Picasso 加载的图像。相关代码如下:

Transformation transformation = new RoundedTransformationBuilder()
            .cornerRadiusDp(4)
            .oval(false)
            .build();

ImageView cardViewTop1Image = (ImageView) cardViewTop1.findViewById(R.id.cv_top1_image);
Picasso.with(cardViewTop1.getContext()).load("http:/some_image_url.com")
            .fit().centerCrop()
            .transform(transformation).into(cardViewTop1Image);

这一切都很好,直到我经历了两次方向变化——首先是水平方向,然后是垂直方向。当我切换回垂直方向时,不再应用圆角变换。

我相信毕加索正在缓存未转换的图像,然后用它填充 ImageView。有没有办法可以缓存转换后的图像或从缓存中加载未转换的图像然后应用转换?感谢您的帮助!

【问题讨论】:

  • 我也看到了类似的问题。已经找到解决这个问题的方法了吗?

标签: android picasso


【解决方案1】:

尝试这种方法停止缓存。

Picasso.with(yourContext)
        .load(yourUrl)
        .memoryPolicy(MemoryPolicy.NO_CACHE )
        .networkPolicy(NetworkPolicy.NO_CACHE)
        .fit()
        .centerCrop()
        .transform(yourTransformation)
        .into(yourImageView);

或者尝试另一个转换。我用这个https://gist.github.com/aprock/6213395

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-06-10
    • 2018-11-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-12-23
    相关资源
    最近更新 更多