I am trying to achieve a karaoke text animation in a Textview. Something like this:
In order for it to be smooth, I want to find a way to draw a 2-color character(like s
in the image).
I found this link but the HalfColorSpan there didn't draw anything.
Is there any way to achieve it?
P/S: I have thought of LinearGradient, but this code only set the gradient VERTICALLY.
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);
}
}