Skip to content

Instantly share code, notes, and snippets.

@brescia123
Created April 19, 2017 08:00
Show Gist options
  • Save brescia123/432306acf981829e5d0a226dd9163bb5 to your computer and use it in GitHub Desktop.
Save brescia123/432306acf981829e5d0a226dd9163bb5 to your computer and use it in GitHub Desktop.
Kotlin useful extension functions for Android
@ColorInt fun Context.color(@ColorRes id: Int, theme: Resources.Theme? = getTheme()): Int =
if (Build.VERSION.SDK_INT >= 23)
resources.getColor(id, theme)
else
resources.getColor(id)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment