23 lines
919 B
Java
23 lines
919 B
Java
|
//设置TextView渐变色
|
||
|
public void setTextViewColor(){
|
||
|
//渐变色
|
||
|
int[] colors = {
|
||
|
Color.parseColor("#E38100"),
|
||
|
Color.parseColor("#F1B868"),
|
||
|
Color.parseColor("#DA9505"),
|
||
|
Color.parseColor("#FDB871"),
|
||
|
Color.parseColor("#E57810")
|
||
|
};
|
||
|
//渐变位置
|
||
|
float[] position = {
|
||
|
0f,
|
||
|
0.2f,
|
||
|
0.4f,
|
||
|
0.8f,
|
||
|
1.0f
|
||
|
};
|
||
|
//设置渐变
|
||
|
LinearGradient mLinearGradient = new LinearGradient(0, 0, title.getPaint().getTextSize() * title.getText().length(), 0, colors, position, Shader.TileMode.CLAMP);
|
||
|
title.getPaint().setShader(mLinearGradient);
|
||
|
title.invalidate();
|
||
|
}
|