Skip to content

Instantly share code, notes, and snippets.

@messenger63
Created April 1, 2016 09:46
Show Gist options
  • Save messenger63/90afc7ccf68a4465ac1a1bc162070746 to your computer and use it in GitHub Desktop.
Save messenger63/90afc7ccf68a4465ac1a1bc162070746 to your computer and use it in GitHub Desktop.
getColoredDrawable
public static Drawable getColoredDrawable(@NonNull Context context, @DrawableRes int drawableRes,
@ColorRes int colorRes) {
Drawable drawable = ContextCompat.getDrawable(context, drawableRes);
int color = ContextCompat.getColor(context, colorRes);
Drawable wrappedDrawable = DrawableCompat.wrap(drawable);
DrawableCompat.setTint(wrappedDrawable, color);
return wrappedDrawable;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment