I am trying to create a karaoke text animation in Textview. Something like that:

To make it smooth, I want to find a way to draw a two-color symbol (for example, sin an image).
I found this link , but HalfColorSpan did not draw anything there.
Is there any way to achieve this?
P / S: I was thinking about LinearGradient, but this code only set the gradient to VERTICAL.
class HalfColorSpan extends CharacterStyle implements UpdateAppearance {
private final static String TAG = "DrawableSpanTest.HalfColorSpan";
@Override
public void updateDrawState(TextPaint paint) {
paint.setStyle(Paint.Style.FILL);
Shader shader = new LinearGradient(0, 0, 0, 80, new int[]{PROCESSED_COLOR, UNPROCESSED_COLOR}, new float[]{0, 1},
Shader.TileMode.CLAMP);
paint.setShader(shader);
}
}
source
share