android-使用滑行时图像质量低

Sim*_*mon 3 android image android-glide

我是android开发的新手。在我的应用中,我有一个horizontalScrollView包含图片的图片。后来我一直在使用Picasso从URL加载图像。然后我听说了滑行,所以我切换到滑行,现在图像加载速度很快,但是图像质量太低。

下面的代码

//load image from URL 1.1
        ivImageFromURL = (ImageView) findViewById(R.id.videoconwmimage);
        Glide.with(this).load("http://imgur.com/KtfpVUb.png").into(ivImageFromURL);
Run Code Online (Sandbox Code Playgroud)

Leo*_*Aso 8

如果您使用的是Glide v4,则在发出Glide请求时,请进行更改

Glide.with(imageView).load(url).into(imageView);
Run Code Online (Sandbox Code Playgroud)

Glide.with(imageView).load(url)
    .apply(new RequestOptions()
            .fitCenter()
            .format(DecodeFormat.PREFER_ARGB_8888)
            .override(Target.SIZE_ORIGINAL))
    .into(imageView);
Run Code Online (Sandbox Code Playgroud)

这样做对我有用,而无需在清单中添加任何内容。将其也添加android:adjustViewBounds="true"ImageViewXML中可能会有所帮助。这些课程是

import com.bumptech.glide.load.DecodeFormat;
import com.bumptech.glide.request.RequestOptions;
import com.bumptech.glide.request.target.Target;
Run Code Online (Sandbox Code Playgroud)

  • 我只用“override(Target.SIZE_ORIGINAL)”就成功了。为什么调用“fitCenter()”和“format()”?我也成功地使用了“dontTransform()”。 (3认同)