I try to draw this on Android canvas, and I have questions...
Why all shaders results have only white and black? There are no colors...
How to set color for more than two points (x,y)?
Where can I find examples that will show simple combinations of use?
Code:
Shader1 = new LinearGradient(0, 0, 0,BarHeight,0xff696969 ,0xffffffff, Shader.TileMode.CLAMP);
Shader2 = new LinearGradient(BarHeight/2, BarHeight/2, 0,34,0xf0696969 ,0xfff34f5f, Shader.TileMode.CLAMP);
ComposeShader mShader = new ComposeShader(Shader2, Shader1, PorterDuff.Mode.MULTIPLY);
GraundPaint.setShader(mShader);
canvas.drawRoundRect(rectf, 0, 0, GraundPaint);
You can set more than 2 points by using this constructor of LinearGradient, which takes an array of colors and the corresponding array of positions (between 0 and 1).
For a simple example using LinearGradient, you may look here.
User contributions licensed under CC BY-SA 3.0