Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

上下两行设置渐变色 #41

Open
ltd920678778 opened this issue Oct 8, 2017 · 4 comments
Open

上下两行设置渐变色 #41

ltd920678778 opened this issue Oct 8, 2017 · 4 comments

Comments

@ltd920678778
Copy link

大神, 想问一下, 就是上下两行的字体绘制时颜色如何才能分开设置呀.
现在代码中上下两行字体的颜色是通过一个paint设置的.
我现在想设置一个渐变色.就是: 第一行是从黑到灰渐变. 第三行是从灰到黑渐变.
不知道要如何改.
望大神解答!
谢谢.

@zkywalker
Copy link

设置线性渐变(LinearGradient)

@ltd920678778
Copy link
Author

Shader shaderTopText = new LinearGradient(0, 0, 0, 20, Color.parseColor("#2f3036"), Color.parseColor("#56575b"), Shader.TileMode.CLAMP);

我设置了, 可是第一行和第三行文字是用同一个paint绘制的所以.

@zkywalker
Copy link

你试试先保存下画布:
canvas.save();
canvas.restore();

@huanting
Copy link

huanting commented Jan 6, 2018

可以在remeasure中设置文字渐变色,通过callback可以设置,类似
public interface TextShaderCallback {
void setShader(Paint paint, int x0, int y0, int x1, int y1);
}
外部模块通过这个回调设置渐变色

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants