【问题标题】:loading image into android imageView with ion returns a blurry result使用 ion 将图像加载到 android imageView 会返回模糊的结果
【发布时间】:2015-09-01 14:18:42
【问题描述】:

我正在尝试使用 ion 库将文件系统中的图像加载到 imageView 中。

当我使用以下代码时:

Ion.with(imageView)
.placeholder(R.drawable.placeholder_image)
.error(R.drawable.error_image)
.load(uri);

它(有时)会导致一种模糊的图像。

当不使用离子时,如下图清晰显示:

imageView.setImageBitmap(BitmapFactory.decodeFile(uri.toString()));

我可以禁用 ion 附带的标准压缩吗?

奇怪的是,在使用 ion 时,并非每张图片都是模糊的,例如我有两个相同的图像,只有另一个名称。当我用离子将它们加载到 imageView 时,一个是模糊的,一个不是。

感谢任何帮助或提示!

【问题讨论】:

  • Ion 尝试加载图像以适应图像视图的边界。因此,请确保您的 imageview 大小正确。或者,如果您使用 adjustViewBounds=true,它不会那样做。或 smartsize(false)
  • 效果很好,这就是我想要的!非常感谢您的解释
  • 酷我添加了答案,所以你可以接受它。

标签: android imageview android-imageview blurry android-ion


【解决方案1】:

Ion 尝试加载图像以适应 ImageView 的边界。因此,请确保您的 ImageView 在布局中的大小正确。或者,如果您使用 adjustViewBounds=true 来指示 ImageView 是由图像内容调整的,它不会这样做。或者 smartsize(false)。

【讨论】:

    【解决方案2】:

    试试这个,

    Ion.with(context)
    .load(url)
    .withBitmap()
    .placeholder(R.drawable.placeholder_image)
    .error(R.drawable.error_image)
    .intoImageView(imageView);
    

    【讨论】:

    • 这似乎只是根据documentation 构建 imageView 请求的 long 方式,并导致完全相同的结果
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-12-17
    • 2019-06-27
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多