|
8 | 8 | import android.graphics.Canvas; |
9 | 9 | import android.graphics.Color; |
10 | 10 | import android.graphics.Paint; |
| 11 | +import android.graphics.PathEffect; |
11 | 12 | import android.graphics.PorterDuff; |
12 | 13 | import android.graphics.PorterDuffColorFilter; |
13 | 14 | import android.graphics.PorterDuffXfermode; |
|
16 | 17 | import android.os.Build; |
17 | 18 | import android.os.Handler; |
18 | 19 | import android.os.Looper; |
| 20 | +import android.support.annotation.Nullable; |
19 | 21 | import android.support.graphics.drawable.AnimatedVectorDrawableCompat; |
20 | 22 | import android.support.v4.content.ContextCompat; |
21 | 23 | import android.support.v7.widget.AppCompatImageView; |
@@ -172,7 +174,7 @@ public class SpotlightView extends FrameLayout { |
172 | 174 | */ |
173 | 175 | private long lineAnimationDuration = 300; |
174 | 176 | private int lineStroke; |
175 | | - |
| 177 | + private PathEffect lineEffect; |
176 | 178 | private int lineAndArcColor = Color.parseColor("#eb273f"); |
177 | 179 |
|
178 | 180 |
|
@@ -578,6 +580,7 @@ private void addPathAnimation(Activity activity) { |
578 | 580 | p.setStrokeCap(Paint.Cap.ROUND); |
579 | 581 | p.setStrokeWidth(lineStroke); |
580 | 582 | p.setColor(lineAndArcColor); |
| 583 | + p.setPathEffect(lineEffect); |
581 | 584 |
|
582 | 585 | NormalLineAnimDrawable animDrawable1 = new NormalLineAnimDrawable(p); |
583 | 586 | if (lineAnimationDuration > 0) |
@@ -893,9 +896,13 @@ public void setLineAndArcColor(int lineAndArcColor) { |
893 | 896 | this.lineAndArcColor = lineAndArcColor; |
894 | 897 | } |
895 | 898 |
|
896 | | -// public void setLineStroke(int lineStroke) { |
897 | | -// this.lineStroke = lineStroke; |
898 | | -// } |
| 899 | + public void setLineStroke(int lineStroke) { |
| 900 | + this.lineStroke = lineStroke; |
| 901 | + } |
| 902 | + |
| 903 | + public void setLineEffect(PathEffect pathEffect) { |
| 904 | + this.lineEffect = pathEffect; |
| 905 | + } |
899 | 906 |
|
900 | 907 | public void setTypeface(Typeface typeface) { |
901 | 908 | this.mTypeface = typeface; |
@@ -1054,10 +1061,15 @@ public Builder enableDismissAfterShown(boolean enable) { |
1054 | 1061 | return this; |
1055 | 1062 | } |
1056 | 1063 |
|
1057 | | -// public Builder lineStroke(int stoke) { |
1058 | | -// spotlightView.setLineStroke(Utils.dpToPx(stoke)); |
1059 | | -// return this; |
1060 | | -// } |
| 1064 | + public Builder lineStroke(int stroke) { |
| 1065 | + spotlightView.setLineStroke(Utils.dpToPx(stroke)); |
| 1066 | + return this; |
| 1067 | + } |
| 1068 | + |
| 1069 | + public Builder lineEffect(@Nullable PathEffect pathEffect) { |
| 1070 | + spotlightView.setLineEffect(pathEffect); |
| 1071 | + return this; |
| 1072 | + } |
1061 | 1073 |
|
1062 | 1074 | public Builder setConfiguration(SpotlightConfig configuration) { |
1063 | 1075 | spotlightView.setConfiguration(configuration); |
|
0 commit comments