How to make the text shimmer in different colors in TextView?
1 answer
As far as I understand, you need a TextView with a gradient. Below is the simplest example of a TextView using a linear gradient:
public class GradientTextView extends TextView { public GradientTextView(Context context) { super(context, null, -1); } public GradientTextView(Context context, AttributeSet attrs) { super(context, attrs, -1); } public GradientTextView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); } @Override protected void onLayout(boolean changed, int left, int top, int right, int bottom) { super.onLayout(changed, left, top, right, bottom); if (changed) { getPaint().setShader( new LinearGradient(0, 0, 0, getHeight(), Color.WHITE, Color.BLACK, Shader.TileMode.CLAMP)); } } } |
