Skip to content

Instantly share code, notes, and snippets.

@colinrtwhite
Last active September 4, 2018 07:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save colinrtwhite/50feeacf2fb5bd97b5fa4a4562581c83 to your computer and use it in GitHub Desktop.
Save colinrtwhite/50feeacf2fb5bd97b5fa4a4562581c83 to your computer and use it in GitHub Desktop.
@CheckResult fun Drawable.tint(@ColorInt color: Int): Drawable {
val tintedDrawable = DrawableCompat.wrap(this).mutate()
DrawableCompat.setTint(tintedDrawable, color)
return tintedDrawable
}
@CheckResult fun Drawable.tint(context: Context, @ColorRes color: Int): Drawable {
return tint(context.getColorCompat(color))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment