I'm using DrawableCompat.wrap to set tint on drawables in pre Lollipop and it's working fine. DrawableCompat.unwrap is not working pre Lollipop. I can't get the original drawable before the tint.
For example:
if (v.isSelected()){
Drawable normalDrawable = getResources().getDrawable(R.drawable.sample);
Drawable wrapDrawable = DrawableCompat.wrap(normalDrawable);
DrawableCompat.setTint(wrapDrawable, getResources().getColor(R.color.sample_color));
imageButton.setImageDrawable(wrapDrawable);
}else{
Drawable normalDrawable = imageButton.getDrawable();
Drawable unwrapDrawable = DrawableCompat.unwrap(normalDrawable);
imageButton.setImageDrawable(unwrapDrawable);
}
In pre lollipop devices DrawableCompact.unwrap returns the drawable with the tint and not the original one
If you want to clear the tint, call
DrawableCompat.setTintList(drawable, null)
.Unwrap
isn't a destructive function, it's only there for you to get access to the original Drawable.The following is an example code:
In your case the code should be: