Skip to content

Instantly share code, notes, and snippets.

@stepango
Created June 9, 2016 13:22
Show Gist options
  • Save stepango/16c4da0549fa6b6e51a35607c3625885 to your computer and use it in GitHub Desktop.
Save stepango/16c4da0549fa6b6e51a35607c3625885 to your computer and use it in GitHub Desktop.
Drawing text with gradient
override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec)
val height = measuredHeight.toFloat()
val width = measuredWidth.toFloat()
val shader = LinearGradient(
0f, 0f, width, height,
intArrayOf(Color.RED, Color.BLUE, Color.GREEN),
null,
Shader.TileMode.CLAMP
)
paint.shader = shader
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment