繁体   English   中英

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

[英]android - image quality is low when using 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);

如果您使用的是Glide v4,那么在进行Glide请求时,请进行更改

Glide.with(imageView).load(url).into(imageView);

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

这对我来说不需要在清单中添加任何东西。 将XML android:adjustViewBounds="true"到XML中的ImageView可能会有所帮助。 课程是

import com.bumptech.glide.load.DecodeFormat;
import com.bumptech.glide.request.RequestOptions;
import com.bumptech.glide.request.target.Target;

这是因为Glide默认位图格式设置为RGB_565,因为与Picasso使用的ARGB_8888相比,它仅消耗了50%的内存占用。

你可以修改它进行以下更改:

public class GlideConfiguration implements GlideModule {

    @Override
    public void applyOptions(Context context, GlideBuilder builder) {
        // Apply options to the builder here.
        builder.setDecodeFormat(DecodeFormat.PREFER_ARGB_8888);
    }

    @Override
    public void registerComponents(Context context, Glide glide) {
        // register ModelLoaders here.
    }
}

并在清单中添加以下内容:

<meta-data android:name="com.inthecheesefactory.lab.glidepicasso.GlideConfiguration"
            android:value="GlideModule"/>

有关详细信息,请访问此处

请检查此链接

滑动负载具有较低的图像质量

https://github.com/bumptech/glide/issues/1227

Glide使用RGB_565不要使用太多内存。 如果默认值对您来说不太好,可以使用Glide.Builder并设置builder.setDecodeFormat(DecodeFormat.ALWAYS_ARGB_8888); 作为您的首选配置。

https://github.com/bumptech/glide/wiki/Configuration检查链接。

暂无
暂无

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM