/**
* 字体颜色渐变
* @param textView
*/
private void setTextViewStyles(TextView textView) {
float x1=textView.getPaint().measureText(textView.getText().toString());//测量文本 宽度
float y1=textView.getPaint().getTextSize();//测量文本 高度
int c1=Color.RED;//初始颜色值
int c2= Color.BLUE;//结束颜色值
LinearGradient leftToRightLG = new LinearGradient(0, 0, x1, 0,c1, c2, Shader.TileMode.CLAMP);//从左到右渐变
LinearGradient topToBottomLG = new LinearGradient(0, 0, 0, y1,c1, c2, Shader.TileMode.CLAMP);//从上到下渐变
textView.getPaint().setShader(leftToRightLG);
textView.invalidate();
}