Skip to content

Commit

Permalink
1,修复bug
Browse files Browse the repository at this point in the history
  • Loading branch information
FlyJingFish committed Apr 11, 2023
1 parent 407a98d commit 4000c9d
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 15 deletions.
29 changes: 15 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,20 +92,21 @@

### 属性一览

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

### 常见问题

Expand Down
2 changes: 1 addition & 1 deletion library/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ android {

dependencies {
implementation 'androidx.appcompat:appcompat:1.3.1'
api 'com.github.FlyJingFish:PerfectTextView:1.1.8'
api 'com.github.FlyJingFish:PerfectTextView:1.1.9'
}
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ public GradientTextView(Context context, AttributeSet attrs,
int endColor = typedArray.getColor(R.styleable.GradientTextView_gradient_endColor, 0);
angle = typedArray.getFloat(R.styleable.GradientTextView_gradient_angle, 0);
rtlAngle = typedArray.getBoolean(R.styleable.GradientTextView_gradient_rtl_angle, false);
int strokeJoinInt = typedArray.getInt(R.styleable.GradientTextView_gradient_stroke_join, Paint.Join.ROUND.ordinal());


typedArray.recycle();

Expand Down Expand Up @@ -94,6 +96,13 @@ public GradientTextView(Context context, AttributeSet attrs,
TextPaint textPaint = backGroundText.getPaint();
textPaint.setStrokeWidth(strokeWidth);
textPaint.setStyle(Paint.Style.FILL_AND_STROKE);
// textPaint.setStrokeCap(Paint.Cap.SQUARE);
if (strokeJoinInt >=0 && strokeJoinInt<=2){
textPaint.setStrokeJoin(Paint.Join.values()[strokeJoinInt]);
}else {
textPaint.setStrokeJoin(Paint.Join.ROUND);
}
// textPaint.setStrokeMiter();
backGroundText.setTextColor(strokeTextColor);
backGroundText.setText(getText());
backGroundText.setGravity(getGravity());
Expand Down
5 changes: 5 additions & 0 deletions library/src/main/res/values/values.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,10 @@

<attr name="gradient_stroke_strokeWidth" format="dimension" />
<attr name="gradient_stroke_textColor" format="color" />
<attr name="gradient_stroke_join" format="enum">
<enum name="miter" value="0" />
<enum name="round" value="1" />
<enum name="bevel" value="2" />
</attr>
</declare-styleable>
</resources>

0 comments on commit 4000c9d

Please sign in to comment.