I've a drawable (res/drawable/my_drawable.xml) which looks like this:
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportHeight="24"
android:viewportWidth="24">
<path
android:fillColor="#aaa"
android:pathData="....." />
</vector>
I want to load this drawable into an ImageView inside onBindViewHolder:
Glide.with(context)
.load(R.drawable.my_drawable)
.into(holder.imageViewProfile);
But it's not working. If I add a listener, an exception is thrown and it's null.
How to load such an vector drawable correctly into an ImageView with Glide?
Alternative is not using Glide, but .... yeah .... that's not what I want.
Glide only supports raster drawables at the moment, see #350 and subscribe to it.
In the meantime you can roll your own solution in two ways:
VectorDrawable and deliver that to the Target.Bitmap of the given size.How I managed to load vector drawable into an ImageView is
Glide.with(mContext)
.load("")
.error(R.drawable.my_vector)
.into(holder.imageView);
Hope this will help you!
@ArbenMaloku isn't that the same as holder.imageView.setImageResource(R.drawable.my_vector)? I guess it's not, but it would need to be confirmed in Glide code. I think the benefit of hacking like this with Glide is that it'll load each drawable in it's own UI cycle which may or may not be a good thing. There's a lot of bookkeeping needed and multiple thread swaps are involved, and I think in the end the drawable is still read and decoded on the main thread.
Most helpful comment
How I managed to load vector drawable into an ImageView is
Glide.with(mContext) .load("") .error(R.drawable.my_vector) .into(holder.imageView);Hope this will help you!