Skip to content

Commit e2afc18

Browse files
committed
1,修改miter显示字母只多出来的箭头
1 parent 92efd9c commit e2afc18

File tree

2 files changed

+24
-15
lines changed

2 files changed

+24
-15
lines changed

README.md

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -94,21 +94,21 @@
9494

9595
### 属性一览
9696

97-
| attr | format | description |
98-
|-----------------------------|:---------------:|:--------------------------------------------------------------:|
99-
| gradient_startColor | color/reference | 前景字体渐变颜色开始颜色 |
100-
| gradient_centerColor | color/reference | 前景字体渐变颜色中心颜色 |
101-
| gradient_endColor | color/reference | 前景字体渐变颜色结束颜色 |
102-
| gradient_angle | float | 前景字体渐变颜色开始角度 |
103-
| gradient_rtl_angle | boolean | 前景字体渐变颜色开始角度是否支持镜像Rtl适配 |
104-
| gradient_stroke_startColor | color/reference | 字体粗边渐变颜色开始颜色 |
105-
| gradient_stroke_centerColor | color/reference | 字体粗边渐变颜色中心颜色 |
106-
| gradient_stroke_endColor | color/reference | 字体粗边渐变颜色结束颜色 |
107-
| gradient_stroke_angle | float | 字体粗边渐变颜色开始角度 |
108-
| gradient_stroke_rtl_angle | boolean | 字体粗边渐变颜色开始角度是否支持镜像Rtl适配 |
109-
| gradient_stroke_strokeWidth | dimension | 字体粗边画笔宽度 |
110-
| gradient_stroke_textColor | color/reference | 字体粗边颜色(设置粗边渐变色之后此属性无效,设置此属性后粗边渐变色也失效) |
111-
| gradient_stroke_join | enum | 字体粗边样式 round/bevel/miter 具体效果自行尝试(不建议使用miter,因为目前发现部分英文字母出现尖头) |
97+
| attr | format | description |
98+
|-----------------------------|:---------------:|:-------------------------------------:|
99+
| gradient_startColor | color/reference | 前景字体渐变颜色开始颜色 |
100+
| gradient_centerColor | color/reference | 前景字体渐变颜色中心颜色 |
101+
| gradient_endColor | color/reference | 前景字体渐变颜色结束颜色 |
102+
| gradient_angle | float | 前景字体渐变颜色开始角度 |
103+
| gradient_rtl_angle | boolean | 前景字体渐变颜色开始角度是否支持镜像Rtl适配 |
104+
| gradient_stroke_startColor | color/reference | 字体粗边渐变颜色开始颜色 |
105+
| gradient_stroke_centerColor | color/reference | 字体粗边渐变颜色中心颜色 |
106+
| gradient_stroke_endColor | color/reference | 字体粗边渐变颜色结束颜色 |
107+
| gradient_stroke_angle | float | 字体粗边渐变颜色开始角度 |
108+
| gradient_stroke_rtl_angle | boolean | 字体粗边渐变颜色开始角度是否支持镜像Rtl适配 |
109+
| gradient_stroke_strokeWidth | dimension | 字体粗边画笔宽度 |
110+
| gradient_stroke_textColor | color/reference | 字体粗边颜色(设置粗边渐变色之后此属性无效,设置此属性后粗边渐变色也失效) |
111+
| gradient_stroke_join | enum | 字体粗边样式 round/bevel/miter 具体效果自行尝试 |
112112

113113

114114

library/src/main/java/com/flyjingfish/gradienttextviewlib/GradientTextView.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ public class GradientTextView extends PerfectTextView {
4545
private ColorStateList strokeTextColor;
4646
private int curStrokeTextColor;
4747
private Paint.Join strokeJoin;
48+
private Float defaultStrokeMiter;
4849

4950
public GradientTextView(Context context) {
5051
this(context, null);
@@ -225,6 +226,14 @@ protected void onDraw(Canvas canvas) {
225226
textPaint.setStrokeWidth(strokeWidth);
226227
textPaint.setStyle(Paint.Style.FILL_AND_STROKE);
227228
textPaint.setStrokeJoin(strokeJoin);
229+
if (defaultStrokeMiter == null){
230+
defaultStrokeMiter = textPaint.getStrokeMiter();
231+
}
232+
if (strokeJoin == Paint.Join.MITER){
233+
textPaint.setStrokeMiter(2.6f);
234+
}else {
235+
textPaint.setStrokeMiter(defaultStrokeMiter);
236+
}
228237
LinearGradient linearGradient;
229238
if (gradientStrokeColor){
230239
float currentAngle = strokeAngle;

0 commit comments

Comments
 (0)