GlideToVectorYou
GlideToVectorYou copied to clipboard
setColorFilter not work
i am load image and set color filter but not work, can you help me ? GlideToVectorYou .init() .with(context) .withListener(new GlideToVectorYouListener() { @Override public void onLoadFailed() { } @Override public void onResourceReady() { if (Build.VERSION.SDK_INT > Build.VERSION_CODES.P) { holder.imgCategory.setColorFilter(BlendModeColorFilterCompat.createBlendModeColorFilterCompat(ContextCompat.getColor(context, R.color.colorWhite), BlendModeCompat.SRC_ATOP)); } else { holder.imgCategory.setColorFilter(new PorterDuffColorFilter(ContextCompat.getColor(context, R.color.colorWhite), PorterDuff.Mode.SRC_IN)); } } }) .load(Uri.parse(category.getAvatar()), holder.imgCategory);
Hello, I also have this type of error also. I try this in two way:
GlideToVectorYou
.init()
.with(view.context)
.withListener(object : GlideToVectorYouListener {
override fun onLoadFailed() {}
override fun onResourceReady() {
view.setColorFilter(ContextCompat.getColor(view.context, colorId))
}
})
.load(imageUri, view)
I also tried to set simply the: view.setColorFilter(ContextCompat.getColor(view.context, colorId))
This worked:
GlideToVectorYou .init() .with(view.context) .withListener(object : GlideToVectorYouListener { override fun onLoadFailed() {}
override fun onResourceReady() {
val paint = Paint()
paint.colorFilter =
PorterDuffColorFilter(ContextCompat.getColor(view.context, colorId), PorterDuff.Mode.SRC_ATOP)
view.setLayerPaint(paint)
}
})
.load(imageUri, view)
It is possible to add something like tintList to an image with this lib?
For PNG i am doing it as below:
Glide.with(getContext()) .asBitmap() .load(url) .listener(listener) .into(new SimpleTarget<Bitmap>() { @Override public void onResourceReady(Bitmap resource, Transition<? super Bitmap> transition) { Drawable drawable = new BitmapDrawable(getResources(), resource); Drawable wrappedDrawable = DrawableCompat.wrap(drawable); DrawableCompat.setTintList(wrappedDrawable, mItemColorState); imageButton.setImageDrawable(wrappedDrawable); } }), getContext(), logoUrl);
This worked:
GlideToVectorYou .init() .with(view.context) .withListener(object : GlideToVectorYouListener { override fun onLoadFailed() {}
override fun onResourceReady() { val paint = Paint() paint.colorFilter = PorterDuffColorFilter(ContextCompat.getColor(view.context, colorId), PorterDuff.Mode.SRC_ATOP) view.setLayerPaint(paint) } }) .load(imageUri, view)
It does not work properly. When you set tint color all of the shape colored as solid. Edit: It works for some type of SVG files, but not all of them.