I want to set gradient as textcolor and also at the same time I want text to have a solid stroke around it as well in a TextView. So far what I have achieved is text can only show gradient or the stroke, not both at the same time.
I've created a custom class with extended TextView and I am using the following methods:
Using this to draw stroke:
paint.setStyle(Paint.Style.STROKE);
paint.setStrokeWidth(_strokeWidth);
setTextColor(_strokeColor);
Which gives me this result:
Using following code to add gradient:
Shader textShader = new LinearGradient(0f, 0f, getWidth(), getTextSize(), gradientColorsArray, null, Shader.TileMode.CLAMP);
paint.setShader(textShader);
And It gives me the following result:
The problem is when I combine the above two methods, The stroke is drawn but the color of the stroke is the same as the gradient I am giving to paint object.
Following is the result I want to achieve. It would be great if somebody can guide me on how to achieve desired results.


