Skip to content

Instantly share code, notes, and snippets.

@subinkrishna
Last active December 7, 2015 03:47
Show Gist options
  • Select an option

  • Save subinkrishna/1a405ab8c707dbdccf1c to your computer and use it in GitHub Desktop.

Select an option

Save subinkrishna/1a405ab8c707dbdccf1c to your computer and use it in GitHub Desktop.
/**
* Returns new color with alpha applied.
*
* @param color
* @param alpha
* @return
*/
public static int getColorWithAlpha(@ColorInt int color,
@FloatRange(from=0.0, to=1.0) float alpha) {
return (int) (0xFF * alpha) << 24 | color & 0xFFFFFF;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment