1

I want to perform multicolour gradient for the text. I am using shader as one of the Stackflow member provided the trick. Following is the code where I am giving multicolour input

Shader textShader=new LinearGradient(100, 375, 100, 450,                
         new int[]{res.getColor(R.color.Red),res.getColor(R.color.Green),Color.MAGENTA},
         null, TileMode.CLAMP);  

but this shades away one of the three color i.e. it get mixes. Not the output which i want. I want three colors to be seen as it is , There is parameter of relative position in my above code its null (colours are evenly distributed) is there any way via which I can get the required output with relative position or something else

Please suggest?

user1169079
  • 3,053
  • 5
  • 42
  • 71
  • Try this... http://stackoverflow.com/questions/2680607/text-with-gradient-in-android – Nitesh Khosla Feb 06 '12 at 13:07
  • I have used one of the solution from there only ... but other boringLayer solution doesnt provide multicolour – user1169079 Feb 06 '12 at 13:28
  • Try this: http://stackoverflow.com/questions/2680607/text-with-gradient-in-android – Nitesh Khosla Feb 06 '12 at 13:10
  • I have used one of the solution from there only ... but other boringLayer solution doesnt provide multicolour. Here atleast shaders allow me to have array of colors and i can tweak with that – user1169079 Feb 06 '12 at 13:29

1 Answers1

0

Haven't tested this, but I saw this overloaded method in the documentation:

public LinearGradient (float x0, float y0, float x1, float y1, int[] colors, float[] positions, Shader.TileMode tile)

Parameters

x0 - The x-coordinate for the start of the gradient line

y0 - The y-coordinate for the start of the gradient line

x1 - The x-coordinate for the end of the gradient line

y1 - The y-coordinate for the end of the gradient line

colors - The colors to be distributed along the gradient line

positions - May be null. The relative positions [0..1] of each corresponding color in the colors array. If this is null, the the colors are distributed evenly along the gradient line.

tile - The Shader tiling mode

*So basically make an array of int with all three of your colors you want and pass that into your LinearGradient, and do the same with an array of float.

http://developer.android.com/reference/android/graphics/LinearGradient.html

SirRupertIII
  • 12,324
  • 20
  • 72
  • 121