Skip to content

Commit 4300519

Browse files
committed
Fix bug when remove HightLightView
1 parent 09332d6 commit 4300519

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

highlight/src/main/java/zhy/com/highlight/HighLight.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
*/
2020
public class HighLight
2121
{
22+
private static final String TAG = "anchorIsFrameLayout";
23+
2224
public static class ViewPosInfo
2325
{
2426
public int layoutId = -1;
@@ -142,7 +144,7 @@ public void show()
142144
ViewGroup.LayoutParams lp = new ViewGroup.LayoutParams
143145
(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
144146
((ViewGroup) mAnchor).addView(hightLightView, ((ViewGroup) mAnchor).getChildCount(), lp);
145-
147+
hightLightView.setTag(TAG);
146148
} else
147149
{
148150
FrameLayout frameLayout = new FrameLayout(mContext);
@@ -154,6 +156,7 @@ public void show()
154156
frameLayout.addView(mAnchor, lp);
155157

156158
frameLayout.addView(hightLightView);
159+
hightLightView.setTag("");
157160
}
158161

159162
if (intercept)
@@ -175,13 +178,14 @@ public void remove()
175178
{
176179
if (mHightLightView == null) return;
177180
ViewGroup parent = (ViewGroup) mHightLightView.getParent();
178-
if (parent instanceof RelativeLayout || parent instanceof FrameLayout)
181+
if (mHightLightView.getTag().equals(TAG))
179182
{
180183
parent.removeView(mHightLightView);
181184
} else
182185
{
183186
parent.removeView(mHightLightView);
184187
View origin = parent.getChildAt(0);
188+
parent.removeView(origin);
185189
ViewGroup graParent = (ViewGroup) parent.getParent();
186190
graParent.removeView(parent);
187191
graParent.addView(origin, parent.getLayoutParams());

0 commit comments

Comments
 (0)