Ich hatte das gleiche Problem. Ich kombinierte die Beiträge in https://stackoverflow.com/a/30928051 und versuchte die APIs 17, 19, 21, 22, 23 und N Preview 3 mit SupportLib 23.4.0, um eine Lösung zu finden.
Auch wenn erwähnt wird, dass die compat-Klasse einen Filter für Pre-Lollipop-Geräte verwendet (siehe https://stackoverflow.com/a/27812472/2170109), funktioniert es nicht.
Jetzt überprüfe ich die API selbst und benutze den folgenden Code, der an allen getesteten APIs funktioniert (für 17 und höher).
// 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);
}
nicht nach der Arbeit mutieren Zugabe() – 3xplore