android-使用滑行时图像质量低 [英] android - image quality is low when using glide

查看:69
本文介绍了android-使用滑行时图像质量低的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I'm new to android developing. In my app, I have a horizontalScrollView that contains images. Later I have been using Picasso to load images from URL. Then I heard about glide so I switched to glide and now my image loading is fast but the quality of images is too low.

下面的代码

//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请求时,请更改

If you are using Glide v4, then when making Glide requests, change

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);

那使我成功了,而不必在清单中添加任何内容.将 android:adjustViewBounds ="true" 也添加到XML的 ImageView 中可能会有所帮助.这些课程是

That did the trick for me without having to add anything to the manifest. It might help to also add android:adjustViewBounds="true" to your ImageView in XML. The classes are

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

这篇关于android-使用滑行时图像质量低的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆