@@ -15,7 +15,7 @@ public class VSpotView2 extends FrameLayout {
15
15
private float density ;
16
16
private List <View > targetViews ;
17
17
private List <RectF > targetRects ;
18
- private VSpotMessageView mMessageView ;
18
+ private VSpotMessageView2 mMessageView ;
19
19
private Gravity mGravity = Gravity .auto ;
20
20
private DismissType dismissType = DismissType .outside ; // Default value
21
21
private boolean mIsShowing = false ;
@@ -61,7 +61,7 @@ private VSpotView2(Context context, List<View> views) {
61
61
}
62
62
63
63
// Message view
64
- mMessageView = new VSpotMessageView (context );
64
+ mMessageView = new VSpotMessageView2 (context );
65
65
addView (mMessageView , new LayoutParams (LayoutParams .WRAP_CONTENT , LayoutParams .WRAP_CONTENT ));
66
66
67
67
// Wait for layout to complete before positioning
@@ -118,6 +118,56 @@ protected void onDraw(Canvas canvas) {
118
118
}
119
119
}
120
120
121
+ private void drawArrowToTarget (Canvas canvas ) {
122
+ RectF target = targetRects .get (currentTargetIndex );
123
+ float targetCenterX = target .centerX ();
124
+ float targetTopY = target .top ;
125
+ float targetBottomY = target .bottom ;
126
+
127
+ float messageX = mMessageView .getX ();
128
+ float messageY = mMessageView .getY ();
129
+ float messageWidth = mMessageView .getWidth ();
130
+ float messageHeight = mMessageView .getHeight ();
131
+
132
+ float arrowCenterX = Math .max (messageX , Math .min (targetCenterX , messageX + messageWidth ));
133
+ float arrowTipX = arrowCenterX ;
134
+ float arrowTipY ;
135
+ boolean drawArrowDownward ;
136
+
137
+ if (messageY > targetBottomY ) {
138
+ // Message is below target – arrow points up
139
+ arrowTipY = messageY ;
140
+ drawArrowDownward = false ;
141
+ } else {
142
+ // Message is above target – arrow points down
143
+ arrowTipY = messageY + messageHeight ;
144
+ drawArrowDownward = true ;
145
+ }
146
+
147
+ float halfWidth = ARROW_WIDTH / 2f ;
148
+ float height = ARROW_HEIGHT ;
149
+
150
+ arrowPath .reset ();
151
+
152
+ if (drawArrowDownward ) {
153
+ // Pointing downward
154
+ arrowPath .moveTo (arrowTipX , arrowTipY );
155
+ arrowPath .lineTo (arrowTipX - halfWidth , arrowTipY - height );
156
+ arrowPath .lineTo (arrowTipX + halfWidth , arrowTipY - height );
157
+ } else {
158
+ // Pointing upward
159
+ arrowPath .moveTo (arrowTipX , arrowTipY );
160
+ arrowPath .lineTo (arrowTipX - halfWidth , arrowTipY + height );
161
+ arrowPath .lineTo (arrowTipX + halfWidth , arrowTipY + height );
162
+ }
163
+
164
+ arrowPath .close ();
165
+
166
+ arrowPaint .setColor (Color .WHITE ); // same as message background
167
+ arrowPaint .setStyle (Paint .Style .FILL );
168
+ canvas .drawPath (arrowPath , arrowPaint );
169
+ }
170
+
121
171
122
172
public void nextTarget () {
123
173
if (currentTargetIndex < targetViews .size () - 1 ) {
0 commit comments