On Sep 9, 1:45 pm, sposnjak <[email protected]> wrote: > Hi all! > > I am working on a custom View that shows a (round) gauge. I would like > to make the background of the scale to go from green to yellow to red > (270 degree scale) to black. The problem I am facing is that I can not > figure out how to make a 90 degree radial gradient - to be specific I > would like to draw a gradient that goes from green to yellow radially > in 90 degrees (and then from yellow to red (in 90 degrees) and from > red do back (again in 90 degrees)). My current code looks like: > > canvas.drawOval(scaleRect, scalePaint); > > canvas.save(Canvas.MATRIX_SAVE_FLAG); > canvas.rotate(-135, 0.5f, 0.5f); > > paintSection.setShader(new RadialGradient(0.0f, 0.0f, 1.0f, > Color.GREEN, Color.YELLOW, Shader.TileMode.REPEAT)); > canvas.drawArc(scaleRect, -90, 90, true, paintSection); > > canvas.rotate(90, 0.5f, 0.5f); > > paintSection.setShader(new RadialGradient(0.0f, 0.0f, 1.0f, > Color.YELLOW, Color.RED, Shader.TileMode.MIRROR)); > canvas.drawArc(scaleRect, -90, 90, true, paintSection); > > canvas.rotate(90, 0.5f, 0.5f); > > paintSection.setShader(new RadialGradient(0.0f, 0.0f, 1.0f, Color.RED, > Color.BLACK, Shader.TileMode.MIRROR)); > canvas.drawArc(scaleRect, -90, 90, true, paintSection); > > canvas.restore(); > > and does not produce the required look. Thank you in advance. > > Regards Simon
Hi, What about using this ctor: RadialGradient (float x , float y, float radius, int[] colors, float[] positions , Shader. TileMode tile ) pskink -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

