diff --git a/library/src/main/java/com/flyjingfish/gradienttextviewlib/GradientTextView.java b/library/src/main/java/com/flyjingfish/gradienttextviewlib/GradientTextView.java index 2fa24bc..6e88eac 100644 --- a/library/src/main/java/com/flyjingfish/gradienttextviewlib/GradientTextView.java +++ b/library/src/main/java/com/flyjingfish/gradienttextviewlib/GradientTextView.java @@ -235,7 +235,7 @@ protected void onDraw(Canvas canvas) { textPaint.setStrokeMiter(defaultStrokeMiter); } LinearGradient linearGradient; - if (gradientStrokeColor){ + if (gradientStrokeColor && gradientStrokeColors != null && gradientStrokeColors.length > 1){ float currentAngle = strokeAngle; if (strokeRtlAngle && isRtl){ currentAngle = - strokeAngle; @@ -251,7 +251,7 @@ protected void onDraw(Canvas canvas) { textPaint.setStrokeWidth(0); textPaint.setStyle(oldStyle); - if (gradientColor){ + if (gradientColor && gradientColors != null && gradientColors.length > 1){ float currentAngle = angle; if (rtlAngle && isRtl){ currentAngle = - angle; @@ -405,7 +405,7 @@ public void setGradientColors(@Nullable ColorStateList[] colorStateLists) { if (gradientColorStates.size() == 1){ gradientColorStates.add(ColorStateList.valueOf(Color.TRANSPARENT)); } - gradientStrokeColor = gradientColorStates.size() > 0; + gradientColor = gradientColorStates.size() > 0; if (gradientPositions != null && gradientColorStates.size() != gradientPositions.length){ this.gradientPositions = null; }