Created
November 9, 2018 15:07
-
-
Save TimCastelijns/8c53b53acdd11f4e1fd3aabf8ce5847b to your computer and use it in GitHub Desktop.
onSizeChanged with linear gradient set up
This file contains hidden or 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 onSizeChanged(w: Int, h: Int, oldw: Int, oldh: Int) { | |
super.onSizeChanged(w, h, oldw, oldh) | |
val colors = intArrayOf( | |
typedArray.getColor(R.styleable.SlickGraph_gradColorStart, defaultColor), | |
typedArray.getColor(R.styleable.SlickGraph_gradColorEnd, defaultColor) | |
) | |
val gradient = LinearGradient( | |
0f, | |
0f, | |
0f, | |
h.toFloat(), | |
colors, | |
null, | |
Shader.TileMode.CLAMP | |
) | |
gradientPaint = Paint() | |
gradientPaint.style = Paint.Style.FILL | |
gradientPaint.shader = gradient | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
i got this. Thanks.