Created
June 9, 2016 13:22
-
-
Save stepango/16c4da0549fa6b6e51a35607c3625885 to your computer and use it in GitHub Desktop.
Drawing text with gradient
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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