private void setTextViewStyles(TextView textView) { int[] colors = {Color.RED, Color.YELLOW, Color.BLUE};//颜色的数组 float[] position = {0f, 0.7f, 1.0f};//颜色渐变位置的数组 LinearGradient mLinearGradient = new LinearGradient(0, 0, textView.getPaint().getTextSize() * textView.getText().length(), 0, colors, position, Shader.TileMode.CLAMP); textView.getPaint().setShader(mLinearGradient); textView.invalidate(); }
自定义字体颜色渐变
最新推荐文章于 2024-08-23 06:12:23 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)