Skip to content

Commit a9b3c3b

Browse files
committed
1、修复bug
1 parent a91e93d commit a9b3c3b

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ protected void onDraw(Canvas canvas) {
235235
textPaint.setStrokeMiter(defaultStrokeMiter);
236236
}
237237
LinearGradient linearGradient;
238-
if (gradientStrokeColor){
238+
if (gradientStrokeColor && gradientStrokeColors != null && gradientStrokeColors.length > 1){
239239
float currentAngle = strokeAngle;
240240
if (strokeRtlAngle && isRtl){
241241
currentAngle = - strokeAngle;
@@ -251,7 +251,7 @@ protected void onDraw(Canvas canvas) {
251251

252252
textPaint.setStrokeWidth(0);
253253
textPaint.setStyle(oldStyle);
254-
if (gradientColor){
254+
if (gradientColor && gradientColors != null && gradientColors.length > 1){
255255
float currentAngle = angle;
256256
if (rtlAngle && isRtl){
257257
currentAngle = - angle;
@@ -405,7 +405,7 @@ public void setGradientColors(@Nullable ColorStateList[] colorStateLists) {
405405
if (gradientColorStates.size() == 1){
406406
gradientColorStates.add(ColorStateList.valueOf(Color.TRANSPARENT));
407407
}
408-
gradientStrokeColor = gradientColorStates.size() > 0;
408+
gradientColor = gradientColorStates.size() > 0;
409409
if (gradientPositions != null && gradientColorStates.size() != gradientPositions.length){
410410
this.gradientPositions = null;
411411
}

0 commit comments

Comments
 (0)