Hiren Hiren - 28 days ago 7
Android Question

how to load xml in imageview using glide

I have created an gradient

xml
in drawable folder of my project. I want to load that
xml
in an
ImageView
using
Glide
. How can I do that ?

Simple loading of image in ImageView using Glide:

Glide.with(LoginActivity.this).load(R.drawable.a270).asBitmap().diskCacheStrategy(DiskCacheStrategy.RESULT).into(backgroundImage);


But if I use the same code above replacing
R.drawable.a270
with
R.drawable.gradient_background
with a drawable xml its not working.

Answer Source

Please try this -

Glide.with(LoginActivity.this).load("").error(R.drawable.gradient_background).diskCacheStrategy(DiskCacheStrategy.RESULT).into(backgroundImage);

OR

Glide.with(LoginActivity.this).load(null).fallback(R.drawable.gradient_background).diskCacheStrategy(DiskCacheStrategy.RESULT).into(backgroundImage);

I doubt you are using VectorDrawable or animated drawable. Please refer this and this for more information on this.