I had the same problem. I combined the posts in https://stackoverflow.com/a/30928051 and tried the APIs 17, 19, 21, 22, 23 and N Preview 3 with SupportLib 23.4.0 to find a solution.
Even if it is mentioned, that the compat-class will use a filter for pre-lollipop-devices (see https://stackoverflow.com/a/27812472/2170109), it's not working.
Now, I check the API myself and use the following code, which is working on all tested APIs (for 17 and up).
// https://stackoverflow.com/a/30928051/2170109
Drawable drawable = DrawableCompat.wrap(ContextCompat.getDrawable(context, R.drawable.vector));
image.setImageDrawable(drawable);
/*
* need to use the filter | https://stackoverflow.com/a/30880522/2170109
* (even if compat should use it for pre-API21-devices | https://stackoverflow.com/a/27812472/2170109)
*/
int color = ContextCompat.getColor(context, R.color.yourcolor);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
DrawableCompat.setTint(drawable, color);
} else {
drawable.mutate().setColorFilter(color, PorterDuff.Mode.SRC_IN);
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…