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.
code below
//load image from URL 1.1
ivImageFromURL = (ImageView) findViewById(R.id.videoconwmimage);
Glide.with(this).load("http://imgur.com/KtfpVUb.png").into(ivImageFromURL);
If you are using Glide v4, then when making Glide requests, change
Glide.with(imageView).load(url).into(imageView);
to
Glide.with(imageView).load(url)
.apply(new RequestOptions()
.fitCenter()
.format(DecodeFormat.PREFER_ARGB_8888)
.override(Target.SIZE_ORIGINAL))
.into(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;
This is because Glide default Bitmap Format is set to RGB_565 since it consumed just 50% memory footprint compared to ARGB_8888 used by Picasso.
you can fix it making following changes:
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.
}
}
And add following to your manifest:
<meta-data android:name="com.inthecheesefactory.lab.glidepicasso.GlideConfiguration"
android:value="GlideModule"/>
For more details visit here
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With